I've always wanted to see the correct rules written down in one place, so I wanted to try to at least the best of my ability. Is this what resolve is supposed to do?
1: All items are private by default, with the exception of struct fields. To flag an item as public, you use `pub`. Also `pub` is not allowed on `impl` or `extern` (visibility is determined by each item individually). 2: For a path which is a cross-crate reference, it is only valid of *every* item in the path is marked as `pub`. 3: A module may access any item from its immediate parent. 4. A module may access any item from its immediate children. 5. Any local-crate path which goes outside the bounds of 3/4 will only resolve if each component of the path is `pub`. For example I could reach into a child's private mod's pub items, but not the child's private mod's non-pub items. Those are the rules that at least make sense to me, I'm not sure if that's what is intended. Regardless, this would make for an awesome compile-fail test to showcase how resolve works. I also wanted to mention #8122 because if these rules are true I don't think that `priv` is needed at all for visibility except for enum variants and struct fields. If possible I'd like to make it a compile error to put `priv` on an item if these rules are true. Do others agree with these rules or are there missing ones? I'd be more than willing to open an issue and curate related issues once we've got these all written down. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
