Skip to content

rustfmt should remove ::{self} in use statements #6278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antonilol opened this issue Aug 12, 2024 · 3 comments
Closed

rustfmt should remove ::{self} in use statements #6278

antonilol opened this issue Aug 12, 2024 · 3 comments
Labels

Comments

@antonilol
Copy link

In my opinion, rustfmt should rewrite use std::io::{self}; to use std::io;. use std::io::{self}; can sometimes be left over after removing other imports. If you for example (automatically) import std::io and std::io::Read (with rust-analyzer) and then remove the Read import, use std::io::{self}; is left behind.

@ytmimi ytmimi added duplicate a-imports `use` syntax labels Aug 13, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Aug 13, 2024

duplicate of #6129 and other similar issues. rustfmt doesn't perform the conversion because use std::io::{self}; and use std::io; are semantically different.

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
@antonilol
Copy link
Author

Would it be possible to have rustfmt figure out if they both refer to the same thing and only then rewrite it?

@calebcartwright
Copy link
Member

Would it be possible to have rustfmt figure out if they both refer to the same thing and only then rewrite it?

Nope. Well more precisely, there's technically a universe in which it could be done but it's note remotely feasible and it's behavior that the tools avoid for good reason (rustfix won't apply this transformation either for the same underlying reasons)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants