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
This lint is intended to help with rust-lang/rustfmt#4709: when using the unstable group_imports = "StdExternalCrate" rustfmt setting (as rustc does now), imports like use local_module::name; are grouped with the "external" imports since, syntactically, they cannot be distinguished. I think it'd be useful to have a lint against that case, making us add an explicit self:: prefix. That makes it easier for rustfmt and the human reader to immediately see that this is a local import.
I implemented this in rust-lang/rust#125645 but I am stuck in "not finding any reviewer hell", so I am suggesting to make this a clippy lint instead which hopefully is less controversial. So, would this lint be acceptable for clippy?
Advantage
Make it syntactically clear which imports are external vs local, both for rustfmt and human readers.
Drawbacks
This feels a bit like going back to 2015 edition imports, maybe?
Example
mod localmod {pubstructS;pubstructT;}// Not a local import, so no lint.use std::cell::Cell;// Implicitly local import, gets lint.use localmod::S;
Could be written as:
mod localmod {pubstructS;pubstructT;}use std::cell::Cell;useself::localmod::S;
The text was updated successfully, but these errors were encountered:
perhaps there should be an option to always use absolute crate::mod imports? that's the style i use in a lot of my projects, since it makes copy-pasting imports from one module to another easy.
rust-lang/rust#125645 has now gotten a review, so maybe we can have it in rustc after all.
perhaps there should be an option to always use absolute crate::mod imports? that's the style i use in a lot of my projects, since it makes copy-pasting imports from one module to another easy.
That's also a possible style but not the one I am looking to enforce here.
What it does
This lint is intended to help with rust-lang/rustfmt#4709: when using the unstable
group_imports = "StdExternalCrate"
rustfmt setting (as rustc does now), imports likeuse local_module::name;
are grouped with the "external" imports since, syntactically, they cannot be distinguished. I think it'd be useful to have a lint against that case, making us add an explicitself::
prefix. That makes it easier for rustfmt and the human reader to immediately see that this is a local import.I implemented this in rust-lang/rust#125645 but I am stuck in "not finding any reviewer hell", so I am suggesting to make this a clippy lint instead which hopefully is less controversial. So, would this lint be acceptable for clippy?
Advantage
Drawbacks
Example
Could be written as:
The text was updated successfully, but these errors were encountered: