-
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
unneeded pub(crate) lint #6199
unneeded pub(crate) lint #6199
Conversation
this lint will tell you if an item is `pub(crate)` but the crate would compile just fine if it weren't.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @phansch (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. |
this includes struct fields, structs/enums/unions, and methods. a bit overzealous right now, actually.
|
☔ The latest upstream changes (presumably #6109) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Thanks for you PR! I'm currently taking a break from reviews so I'm going to re-assign this - r? @llogiq |
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 like this lint, and I very much want to use it on my code. r=me once the ICE is fixed.
}, | ||
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self | ||
.maybe_typeck_results | ||
.and_then(|typeck_results| typeck_results.type_dependent_def(hir_id)), |
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 is the line where the ICE appears to happen. I'm not deep enough into typeck_results
to know where the problem stems from, but I think I've seen something similar in the past. I'll need a bit of time to check, though.
Edit: It's likely because you call typeck_results
from a visitor – usually you want to do this directly in the lint pass (which as you know is a visitor of sorts by itself).
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.
@llogiq i run this visitor in the context of the lint pass, down in check_crate_post
. is that what you mean?
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.
my best guess is that there are qpaths that i'm not supposed to look up, maybe that LangItem
case?
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 completely sure, but I'd hope rewriting this into a single pass (where you'd collect refs to items and references to them, and finally linting all non-publicly ref'd ones) might fix it.
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
☔ The latest upstream changes (presumably #6070) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
i plan on coming back to this next week! |
ping from triage @emberian. Could you have any update on this? |
ping from triage @emberian. According to triage procedure, I'm closing this because 2 weeks have passed with no activity. If you have more time to work on this, feel free to reopen. |
this lint will tell you if an item is
pub(crate)
but the crate would compile just fine if it weren't. it does this check by looking at all uses of eachpub(crate)
item (call itW
). if the module the usage ofW
occurs within is a submodule (or the same module) of the parent ofW
, this usage would have succeeded if thepub(crate)
were absent.open question: should the
redundant_pub_crate
lint (which is a... subset of this one?) be folded into this lint pass? does the checkredundant_pub_crate
does ever fire when this lint wouldn't?h/t @eddyb who helped me finagle the visitor infrastructure.
If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.
.stderr
file)cargo test
passes locallycargo dev update_lints
cargo dev fmt
Please keep the line below
changelog: Add unneeded_pub_crate lint