Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

emberian
Copy link
Member

@emberian emberian commented Oct 20, 2020

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 each pub(crate) item (call it W). if the module the usage of W occurs within is a submodule (or the same module) of the parent of W, this usage would have succeeded if the pub(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 check redundant_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.

  • Followed [lint naming conventions][lint_naming]
  • Added passing UI tests (including committed .stderr file)
  • cargo test passes locally
  • Executed cargo dev update_lints
  • Added lint documentation
  • Run cargo dev fmt

Please keep the line below
changelog: Add unneeded_pub_crate lint

this lint will tell you if an item is `pub(crate)` but the crate would
compile just fine if it weren't.
@rust-highfive
Copy link

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 20, 2020
this includes struct fields, structs/enums/unions, and methods. a bit overzealous right now, actually.
@emberian emberian changed the title [WIP] unneeded pub(crate) lint unneeded pub(crate) lint Oct 21, 2020
@emberian
Copy link
Member Author

  1. this lint doesn't check positional fields. it needs to, i think?
  2. there's an ICE in type_dependent_def that i don't understand.
  3. the latest commit broke the test way more than just not fixing the positional fields. why?
  4. more test cases?

@bors
Copy link
Contributor

bors commented Oct 25, 2020

☔ 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:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@phansch
Copy link
Member

phansch commented Nov 4, 2020

Thanks for you PR! I'm currently taking a break from reviews so I'm going to re-assign this - r? @llogiq

@rust-highfive rust-highfive assigned llogiq and unassigned phansch Nov 4, 2020
Copy link
Contributor

@llogiq llogiq left a 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)),
Copy link
Contributor

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).

Copy link
Member Author

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?

Copy link
Member Author

@emberian emberian Nov 16, 2020

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?

Copy link
Contributor

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.

@llogiq
Copy link
Contributor

llogiq commented Nov 7, 2020

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@bors
Copy link
Contributor

bors commented Nov 17, 2020

☔ 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

@llogiq
Copy link
Contributor

llogiq commented Nov 28, 2020

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@emberian
Copy link
Member Author

i plan on coming back to this next week!

@giraffate
Copy link
Contributor

ping from triage @emberian. Could you have any update on this?

@giraffate
Copy link
Contributor

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.

@giraffate giraffate closed this Jan 26, 2021
@giraffate giraffate added S-inactive-closed Status: Closed due to inactivity and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive-closed Status: Closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants