Making an issue off of my email to the mailing list.
Currently today resolve is generally considered "broken", and I think that this would benefit from actually writing the rules down, writing lots of test cases and documentation, and then fixing resolve. To the best of my knowledge, these are the rules which resolve should follow for determining whether an item is public or private and whether a certain path should resolve or not:
- 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).
- For a path which is a cross-crate reference, it is only valid of every
item in the path is marked as pub.
- A module may access any item from its immediate parent.
- A module may access any item from its immediate children.
- 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.
I'm nominating for a backwards-compatibility milestone as there's probably lots of existing code which is doing the wrong thing by accident.
Making an issue off of my email to the mailing list.
Currently today resolve is generally considered "broken", and I think that this would benefit from actually writing the rules down, writing lots of test cases and documentation, and then fixing resolve. To the best of my knowledge, these are the rules which resolve should follow for determining whether an item is public or private and whether a certain path should resolve or not:
To flag an item as public, you use
pub. Alsopubis not allowed onimplor
extern(visibility is determined by each item individually).item in the path is marked as
pub.if each component of the path is
pub. For example I could reach into achild's private mod's pub items, but not the child's private mod's non-pub
items.
I'm nominating for a backwards-compatibility milestone as there's probably lots of existing code which is doing the wrong thing by accident.