You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
We should use crate visibility in implementation details like std::sys. #69737
@pnkfelix brought up during the compiler meeting that #67705 is "adding a pub fn to std::sys::windows", which turned out not to be a concern as std::sys itself is private.
However I think it would be helpful (and prevent accidental reexports), if everything under std::sys (and anything like it) had crate-level visibility instead of pub.
This pattern (pub in a private module) is actually very common in Rust code. If this is something that we want to discourage then we may want a lint for this: e.g. public item is not exported outside the current crate, considering using pub(crate) instead.
This pattern (pub in a private module) is actually very common in Rust code.
And sometimes it's needed, e.g. bounds on pub traits that are never exported.
Also, crate-level visibility is much newer than the pattern, so I'm not surprised.
I'm not as concerned about user code, I just think the standard library should be aggressive about hiding implementation details since it's not versioned in the same way as libraries on crates.io are.
The stability system probably prevents any accidental reexports anyway, so this isn't as important to that end, I suppose.
Activity
Amanieu commentedon Mar 5, 2020
This pattern (
pubin a private module) is actually very common in Rust code. If this is something that we want to discourage then we may want a lint for this: e.g. public item is not exported outside the current crate, considering usingpub(crate)instead.sfackler commentedon Mar 5, 2020
I think that style of lint could be interesting.
jhpratt commentedon Mar 5, 2020
Isn't that the
unreachable_publint?eddyb commentedon Mar 5, 2020
And sometimes it's needed, e.g. bounds on
pubtraits that are never exported.Also, crate-level visibility is much newer than the pattern, so I'm not surprised.
I'm not as concerned about user code, I just think the standard library should be aggressive about hiding implementation details since it's not versioned in the same way as libraries on crates.io are.
The stability system probably prevents any accidental reexports anyway, so this isn't as important to that end, I suppose.