-
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
single_component_path_imports
: ignore pub(crate) use some_macro;
#7120
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -105,14 +119,22 @@ fn track_uses( | |||
ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) => { | |||
check_mod(cx, &items); | |||
}, | |||
ItemKind::MacroDef(MacroDef { macro_rules: true, .. }) => { |
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 had a brief look at the macros 2.0 RFC, and it seems like it will introduce a better way of declaring a macro's visibility:
pub(crate) macro foo { /* ... */ }
That's why I've included macro_rules: true
so this only applies to macro_rules!
macros, but I'm not too sure about this.
ItemKind::Use(use_tree) => { | ||
let segments = &use_tree.prefix.segments; | ||
|
||
let should_report = | ||
|name: &Symbol| !macros.contains(name) || matches!(item.vis.kind, VisibilityKind::Inherited); |
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.
When I remove the &Symbol
type annotation, I get this error:
error[E0597]: `name` does not live long enough
--> clippy_lints/src/single_component_path_imports.rs:150:50
|
150 | ... if should_report(&name) {
| ------------- ^^^^^ borrowed value does not live long enough
| |
| borrow later used here
...
153 | ... }
| - `name` dropped here while still borrowed
@bors r+ |
📌 Commit b48699e has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #7106
Please write a short comment explaining your change (or "none" for internal only changes)
changelog: Ignore exporting a macro within a crate using
pub(crate) use some_macro;
for [single_component_path_imports
]