-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow use super::*;
glob imports
#5564
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.
A good heuristic would be to check if the name of module we're currently in, contains the string "test". You can do this by setting a flag self.in_test_module = true
in a check_item
function and reset it in check_item_post
. Documentation: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.BuiltinCombinedLateLintPass.html#method.check_item_post
You cannot check for the |
Since |
We could add this, yes |
Updated to check for "test" in the parent module name. I ended up doing this inline for simplicity's sake, happy to set a field on WildcardImports if that seems better. |
That was my first idea when I reviewed this PR too. But that doesn't work, if the super import isn't directly in the main module. And allowing |
Better than a bool would be to add a counter how many test modules deep the lint check is, so it doesn't start linting in test modules again, just because a submodule is also called |
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.
Thanks for also implementing #5569!
Okay, updated to remove that field and check the itemkind. I checked for either Also - are there docs I should update as well? |
@MrAwesome Thanks! It's great to see it will be available immediately with this PR. |
Yes please exclude |
Updated to use Mod only, reflected that in the tests, and updated the docs to reflect all the new functionality. |
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.
Please rebase on top of master to get rid of the merge commits.
This look correct? Most of my experience is with Mercurial so I want to make extra sure I don't cause some weird repo state. |
…ard import exceptions
Perfect, thanks! @bors r+ |
📌 Commit b69200b has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: Allow super::* glob imports
fixes #5554
fixes #5569
A first pass at #5554 - this allows all
use super::*
to pass, which may or may not be desirable. The original issue was around allowing test modules to import their entire parent modules - I'm happy to modify this to do that instead, may just need some guidance on how to implement that (I played around a bit with #[cfg(test)] but from what I can gather, clippy itself isn't in test mode when running, even if the code in question is being checked for the test target).