Skip to content

Commit c347f0a

Browse files
committed
Update pub(in path) for 2018.
When updating paths, I neglected to add a note that visibility paths must be absolute.
1 parent e57b2ee commit c347f0a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/visibility-and-privacy.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,18 @@ be a parent module of the item whose visibility is being declared.
154154
- `pub(self)` makes an item visible to the current module. This is equivalent
155155
to `pub(in self)`.
156156

157+
> **Edition Differences**: Starting with the 2018 edition, paths for
158+
> `pub(in path)` must start with `crate`, `self`, or `super`.
159+
157160
Here's an example:
158161

159162
```rust
160163
pub mod outer_mod {
161164
pub mod inner_mod {
162165
// This function is visible within `outer_mod`
163-
pub(in outer_mod) fn outer_mod_visible_fn() {}
166+
pub(in crate::outer_mod) fn outer_mod_visible_fn() {}
167+
// Same as above, this is only valid in the 2015 edition.
168+
pub(in outer_mod) fn outer_mod_visible_fn_2015() {}
164169

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

0 commit comments

Comments
 (0)