Skip to content

Update pub(in path) for 2018. #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/visibility-and-privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,18 @@ be a parent module of the item whose visibility is being declared.
- `pub(self)` makes an item visible to the current module. This is equivalent
to `pub(in self)`.

> **Edition Differences**: Starting with the 2018 edition, paths for
> `pub(in path)` must start with `crate`, `self`, or `super`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this just a consequence of the path having to be absolute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there is nothing else that explicitly calls that out for visibility paths. The only other part is the "use declarations", which only talk about the requirements in use declarations. Or are you saying it should be worded differently?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise how the reference described paths in use items. The wording here is probably fine, but I think that there should be some wording on how paths that start with an identifier are resolved in the 2015 edition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch!


Here's an example:

```rust
pub mod outer_mod {
pub mod inner_mod {
// This function is visible within `outer_mod`
pub(in outer_mod) fn outer_mod_visible_fn() {}
pub(in crate::outer_mod) fn outer_mod_visible_fn() {}
// Same as above, this is only valid in the 2015 edition.
pub(in outer_mod) fn outer_mod_visible_fn_2015() {}

// This function is visible to the entire crate
pub(crate) fn crate_visible_fn() {}
Expand Down