-
Notifications
You must be signed in to change notification settings - Fork 13.9k
librustc_*: Use pub(crate)
instead of pub
and remove dead code
#43192
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
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc/lint/mod.rs
Outdated
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.
Just use :vis
to combine all 3 arms here?
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.
Ugh, it requires #![feature(macro_vis_matcher)]
in all crates where the macro containing it is used, including tests.
pub(crate)
instead of pub
and remove dead codepub(crate)
instead of pub
and remove dead code
src/librustc_back/dynamic_lib.rs
Outdated
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.
Any chance a bunch of these are used on only some host OSes?
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.
Looks like no, but CI should catch if I missed anything.
We'd be lucky if something like that does not break Clippy. Cc @Manishearth, @llogiq, @oli-obk |
This is great! Would you be so kind and also test whether clippy and miri keep building and adjust your PR accordingly? |
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 did a pass over rustc_data_structures
.
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 keep this one.
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 think it makes sense to keep this type publicly available.
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 keep these pub
.
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 keep this pub
.
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 keep pub
.
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 keep pub
.
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 keep pub
.
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 keep pub
.
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 keep pub
.
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 still seems like a useful type to have.
Thanks! |
265ae78
to
55694ca
Compare
Updated, comments addresses. |
src/librustc_allocator/lib.rs
Outdated
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.
is_unsafe
being unused looks like a bug. It should be used in expansion, but it's ignored and all methods are expanded as unsafe.
@alexcrichton, is this intentional or just an omission?
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.
Ah yes historically used but no longer used! Should be safe to remove.
9b1c051
to
9153114
Compare
I think these changes look good. I am sad to see some of the code go (e.g., useful algorithms on graphs etc), but I think that it's best to kill dead code. Those bits are still around in the git history if we ever want them. (In any case, I suspect we should start moving the |
ping r? @eddyb |
src/librustc_errors/lib.rs
Outdated
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.
Good riddance! 🎉
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.
Was the generator for these updated?
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.
Updated in the latest commit.
src/librustc_privacy/lib.rs
Outdated
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.
Is this correct? Seems a mistake.
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.
Ha, I fixed several similar cases, but haven't seen this one.
I grepped a bit harder and found a few more, fixed in the last commit.
src/librustc_typeck/diagnostics.rs
Outdated
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.
Is this file some sort of rebase failure?
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.
Went through the entire diff and left some comments. Not that worried about deletions, because of git history, but some of the changes seemed unintentional.
src/librustc_save_analysis/lib.rs
Outdated
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.
These Data
structures should all be pub
still, they are expected to be used by clients
src/librustc_save_analysis/lib.rs
Outdated
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.
LIkewsie this trait and the functions below are API and should still be public
src/librustc_driver/driver.rs
Outdated
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.
These fields should still be pub
src/librustc_driver/driver.rs
Outdated
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 think this should be pub
still
src/librustc_driver/driver.rs
Outdated
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.
All these changes from here on down are bogus and should still be pub.
src/librustc_driver/lib.rs
Outdated
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.
pub
src/librustc_driver/lib.rs
Outdated
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.
pub
src/librustc_driver/lib.rs
Outdated
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.
pub
src/librustc_driver/lib.rs
Outdated
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.
pub
src/librustc_errors/diagnostic.rs
Outdated
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.
pretty much everything here should be pub
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.
where 'here' = all of the _errors crate
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 made all the interface of Diagnostic
public, but kept stuff in other modules containing implementation details crate-private.
I think that any change from pub -> pub(crate) in a non-public module is just noise (both in the git history and the source code). I think I'm generally a bit sad about how much noisier this is making the code, even if the tighter encapsulation and dead code removal have benefits. |
☔ The latest upstream changes (presumably #43183) made this pull request unmergeable. Please resolve the merge conflicts. |
Revert some `pub(crate)`s to `pub`s to make sure Miri and Clippy work Revert some `pub(crate)`s to `pub`s to address Michael Woerister's comments
Rebased, comments addressed. |
Interesting, this was kinda the point for me. |
pub(crate)
instead of pub
and remove dead codepub(crate)
instead of pub
and remove dead code
☔ The latest upstream changes (presumably #43387) made this pull request unmergeable. Please resolve the merge conflicts. |
This is pretty much a weakness in Rust's privacy system (and one the lang team has been debating recently). Does the privacy annotation on an item mean that item is 'at most' this public or 'at least' this public? Using Given that this is only helpful for crate-level encapsulation and it is so noisey, I'd prefer not to do it. |
At least with |
The primary benefit from |
This probably needs some collective decision from people working on these crates.
|
I think the dead code removal is certainly worth landing. I would prefer not to land the rest, however, I don't work much on the crates which are mostly affected so if others want the changes, I won't object. |
This annoys me too, btw. |
@petrochenkov looks like this needs a rebase!
Who are you referring to here? i.e. is this with a rust team to come to a decision? |
@aidanhs @rfcbot fcp merge Questions:
|
@rfcbot fcp merge |
Team member @eddyb has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Too much bit rot and not enough interest, closing. |
This PR does the next things:
pub
s inlibrustc*
crates (except forlibrustc
itself) withpub(crate)
s.x.py test
from passing and RLS/Miri/Clippy from building.The changes are 99% mechanical. I didn't judge and (semi-automatically) removed everything the compiler told me. Now this needs to be reviewed and some false positives need to be reverted (either for interface completeness or because they are needed by some third party tools).
EDIT: Changes mentioned in review comments are reverted.
cc @nikomatsakis and @michaelwoerister for
rustc_data_structures
cc @nrc for
librustc_driver
APIs and toolscc @rust-lang/compiler for everything else, if you see something that should be kept please leave a comment!
Next steps after reviewing:
pub(crate)
with nothing in crate roots.