-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add #[warn(unreachable_pub)]
to a bunch of compiler crates
#126013
Conversation
Some changes occurred in coverage instrumentation. cc @Zalathar |
312e01b
to
fe6d4ca
Compare
This comment has been minimized.
This comment has been minimized.
fe6d4ca
to
800b92a
Compare
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 my 2 cents: I prefer the style where you just use pub
in the internal modules, and then limit visibility in the parent (for multiple reasons, one of them being that pub(crate)
is IMO too verbose). It seems to be more uniform to me, in the sense that you export things from the module, and then decide in the parent what to export further and what not to export, rather than hard-coding the visibility to the whole crate in nested modules.
For example, in rustc_ast_lowering/src/lib.rs
, all modules are actually private, and the crate selectively exports (or declares as pub
in the root library module) just a few selected items. It doesn't seem to me that adding pub(crate)
to many items in the nested modules (which are not reexported from the crate anyway) adds a lot of value.
Given the concerns expressed by others, I withdraw my approval.
Yeah, this is far more reaching than what I was asking for in the original PR (diagnostic structs). I don't have the energy to review this and also don't think we're gaining much -- this really seems like churn. r? compiler |
r? @Urgau since you seem interested in solving this |
I personally hate having to look at some outer level (sometimes the immediate struct, sometimes the module, sometimes a |
I also don't understand why this change would be desirable on diagnostic structs but not on other things. |
It would be nice if IDEs could show the computed crate visibility on the struct/field. That way we could see both the final visibility, without having to specify But otherwise, this is just a matter of taste, of course. |
I also don't like to look elsewhere, but in case of nearly all structs and many impls the outer visibility is in the immediate proximity of the fields/methods, or at worst on the same page. In those cases it's better to avoid the noise and keep just |
☔ The latest upstream changes (presumably #126108) made this pull request unmergeable. Please resolve the merge conflicts. |
While I like this change, the concerns expressed by others makes me realize that this change is probably to big to just be approved without further discussion. The major change proposal page on the forge quotes changing coding conventions as a potential reason for an MCP. @nnethercote if you are interested in pursuing this change further, could you open an MCP for it. @rustbot author |
800b92a
to
4af8178
Compare
I have updated this PR for the new |
This comment has been minimized.
This comment has been minimized.
But explain why.
f452be0
to
cc84442
Compare
#[deny(unreachable_pub)]
to a bunch of compiler crates#[warn(unreachable_pub)]
to a bunch of compiler crates
@Urgau: the MCP has passed, so this is ready for final review. Thanks! |
@bors r+ rollup |
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#126013 (Add `#[warn(unreachable_pub)]` to a bunch of compiler crates) - rust-lang#128157 (deduplicate and clarify rules for converting pointers to references) - rust-lang#129032 (Document & implement the transmutation modeled by `BikeshedIntrinsicFrom`) - rust-lang#129250 (Do not ICE on non-ADT rcvr type when looking for crate version collision) - rust-lang#129340 (Remove Duplicate E0381 Label) - rust-lang#129560 ([rustdoc] Generate source link on impl associated types) - rust-lang#129622 (Remove a couple of unused feature enables) - rust-lang#129625 (Rename `ParenthesizedGenericArgs` to `GenericArgsMode`) - rust-lang#129626 (Remove `ParamMode::ExplicitNamed`) Failed merges: - rust-lang#128166 (Improved `checked_isqrt` and `isqrt` methods) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#126013 - nnethercote:unreachable_pub, r=Urgau Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
…rgau More `unreachable_pub` Add `unreachable_pub` checking to some more compiler crates. A follow-up to rust-lang#126013. r? `@Urgau`
…rgau More `unreachable_pub` Add `unreachable_pub` checking to some more compiler crates. A follow-up to rust-lang#126013. r? ``@Urgau``
Rollup merge of rust-lang#129648 - nnethercote:unreachable_pub-2, r=Urgau More `unreachable_pub` Add `unreachable_pub` checking to some more compiler crates. A follow-up to rust-lang#126013. r? ``@Urgau``
By default
unreachable_pub
identifies things that need not bepub
and tells you to make thempub(crate)
. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then addpub(crate)
back in everywhere the compiler said it was necessary. (Or occasionallypub(super)
when context suggested that was appropriate.) Tedious, but results in morepub
removal.There are plenty more crates to do but this seems like enough for a first PR.
r? @compiler-errors