I edited the last section of my first post. First of all this should be introduced after
pub(restricted) is stable -
pub(restricted) also works for traits. It should be a WARNING, not an error (changed title). Rayon should use
pub(crate) to limit the scope of their public types to the rayon crate.
This discussion was already done here: https://github.com/rust-lang/rust/issues/35005 and it ended with “won’t change because current system is working”. Yes, it’s working, but it’s not working nicely.
If the community still says “it’s ok”, we can end this discussion because it would lead nowhere.
Exposing non-accessible items in public APIs is not a good design because it confuses outside library users (my opinion). Meanwhile you still want flexibility like exposing structs / traits within your crate, but not expose them in a public API. This could be solved by using
Rayon, etc. did it this way because they had no other choice. There is simply no way to do it in stable yet. The logical decision would be to postpone this until after
pub(restricted), otherwise it would warn needlessly in crates like this.
Again, there are several things I’ve changed in correction to my original post:
- It’s a warning, not an error, it can be turned off.
- Do this after
pub(restricted) is stable and advise people to either check their libraries API or use
pub should be handled like