-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
New Lint: wildcard imports
#5029
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we could move the enum_glob_use
lint into this one. It appears, that this lint catches use Enum::*
s, that enum_glob_use
doesn't catch. Also we could provide a suggestion for the enum_glob_use
lint by moving it into this LintPass
.
@@ -153,8 +153,6 @@ impl Constant { | |||
|
|||
/// Parses a `LitKind` to a `Constant`. | |||
pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant { | |||
use syntax::ast::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produced one unused_imports
warning, since FloatTy
and LitKind
was imported twice after fixing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth adding this to the Known Problems
section?
☔ The latest upstream changes (presumably #5040) made this pull request unmergeable. Please resolve the merge conflicts. |
b5ab922
to
719526f
Compare
Done in 12937f0 |
☔ The latest upstream changes (presumably #5034) made this pull request unmergeable. Please resolve the merge conflicts. |
Is the import-use query overeager? The The |
Yes it appears to be, but as long as it introduces only warnings, this should be ok.
FloatTy and LitKind was imported twice: once on the module level and once on the function level (with a *). This probably only happens by accident and should be fixed, by either only importing it at function level or at module level. But IMO the user has to decide where he wants this import. So signaling this by producing an |
719526f
to
737c3cf
Compare
☔ The latest upstream changes (presumably #5140) made this pull request unmergeable. Please resolve the merge conflicts. |
IMO, this lint shouldn't warn about prelude modules since their only purpose is to be glob imported. Or if it does, it should resolve the re-exports. Suggesting something like |
737c3cf
to
3ada27d
Compare
☔ The latest upstream changes (presumably #5148) made this pull request unmergeable. Please resolve the merge conflicts. |
c4b3534
to
0e8f8bd
Compare
☔ The latest upstream changes (presumably #5182) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits, apart from that it looks good to me 💯
@@ -153,8 +153,6 @@ impl Constant { | |||
|
|||
/// Parses a `LitKind` to a `Constant`. | |||
pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant { | |||
use syntax::ast::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth adding this to the Known Problems
section?
c91a9fb
to
cc13da5
Compare
☔ The latest upstream changes (presumably #5202) made this pull request unmergeable. Please resolve the merge conflicts. |
cc13da5
to
2483017
Compare
Queries are cool, but too hard to find.
2483017
to
4dd2252
Compare
@bors r+ |
📌 Commit 4dd2252 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #1228
A few notes:
cargo fix
(This produced 3unused_imports
warnings) and are in commit 7e834c8. So reverting these changes wouldn't be a problem.A few ideas:
*
might be better.A configuration to disable the lint for enums. Or just disable the lint for enums, since there isI movedenum_glob_use
enum_glob_use
into this lint in 12937f0A few quotes from the issue:
Yes there is. I found it, once I was nearly finished implementing it myself. See 321d64a
Yeah that was pretty hard, until I found the query for this. Queries are cool, but too hard to find.
And now, Clippy can do this too! 🎉
Your thoughts on the notes/ideas?
changelog: Add new lint [
wildcard imports
]. Add suggestion to [enum_glob_use
]