You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We discussed this in the @rust-lang/lang meeting. We agreed that 1) there should be a lint for this, and 2) ideally it should be a fixed version of the redundant import lint.
This would be a good lint to have because many beginners speculate that use foo; brings foo into scope, as opposed to the actual situation that use foo::bar; brings bar into scope given that fooalready is in scope. In my opinion, it would be best if
The lint has help that specifically explains that 1-element paths in use usually do nothing and are only useful in special cases (pub use, as).
The lint is deny-by-default in a future edition, because it indicates a misunderstanding of the module/crate/path system which is likely to result in follow-up errors (such as if they assume that use foo; works like use foo::*;), so the user should be promptly told “this won't help”. (Many beginners will completely ignore warnings while trying to fix an error.)
Activity
petrochenkov commentedon Jun 8, 2019
This is an extension of the "redundant import" lint implemented in #58805.
Right now it covers imports in blocks
but not in modules (due to some complexities described in #10178 (comment)).
joshtriplett commentedon Jun 20, 2019
We discussed this in the @rust-lang/lang meeting. We agreed that 1) there should be a lint for this, and 2) ideally it should be a fixed version of the redundant import lint.
kpreid commentedon May 26, 2022
This would be a good lint to have because many beginners speculate that
use foo;
bringsfoo
into scope, as opposed to the actual situation thatuse foo::bar;
bringsbar
into scope given thatfoo
already is in scope. In my opinion, it would be best ifuse
usually do nothing and are only useful in special cases (pub use
,as
).use foo;
works likeuse foo::*;
), so the user should be promptly told “this won't help”. (Many beginners will completely ignore warnings while trying to fix an error.)petrochenkov commentedon Mar 2, 2024
This was implemented in #117772.
There was a large ecosystem fallout though, so #121708 now discusses how to release this change better.