Add #[warn(unreachable_pub)]
to a bunch of compiler crates by nnethercote · Pull Request #126013 · rust-lang/rust (original) (raw)
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.