-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add new lint: std_wildcard_imports
#14868
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
base: master
Are you sure you want to change the base?
Conversation
3a0a721
to
5f8b8e3
Compare
std_wildcard_imports
std_wildcard_imports
This comment has been minimized.
This comment has been minimized.
5f8b8e3
to
80ac147
Compare
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.
There seems to be some duplication with the wildcard_imports
lint. It probably makes sense to pull those lint passes together into one pass that implements both lints.
Otherwise I'm dubious about making this a warn-by-default lint, but we can discuss this during the final comment period.
/// Wildcard imports can pollute the namespace. This is especially bad when importing from the | ||
/// standard library through wildcards: | ||
/// | ||
/// ```no_run |
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 belongs into the Example
section.
/// ``` | ||
#[clippy::version = "1.89.0"] | ||
pub STD_WILDCARD_IMPORTS, | ||
style, |
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.
I'm not sure about the lint group. Yes, namespace pollution is bad. But there are four stdlib namespaces (of which three might be imported from in somewhat normal code), so this could lead to serious churn.
I also don't follow the argument that names imported from std are somehow worse than others. Why? The standard library moves slower than other crates if anything.
cx, | ||
STD_WILDCARD_IMPORTS, | ||
span, | ||
"usage of wildcard import from `std` crates", |
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 would be shorter and clearer to replace the "std
crates" with the actual crate name.
☔ The latest upstream changes (possibly 84ef7fb) made this pull request unmergeable. Please resolve the merge conflicts. |
changelog: [
std_wildcard_imports
]: Initial implementationThis fixes #13961.
Please let me know if there any missing test cases and/or changes!
TODO