]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0742.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0742.md
1 Visibility is restricted to a module which isn't an ancestor of the current
2 item.
3
4 Erroneous code example:
5
6 ```compile_fail,E0742,edition2018
7 pub mod Sea {}
8
9 pub (in crate::Sea) struct Shark; // error!
10
11 fn main() {}
12 ```
13
14 To fix this error, we need to move the `Shark` struct inside the `Sea` module:
15
16 ```edition2018
17 pub mod Sea {
18     pub (in crate::Sea) struct Shark; // ok!
19 }
20
21 fn main() {}
22 ```
23
24 Of course, you can do it as long as the module you're referring to is an
25 ancestor:
26
27 ```edition2018
28 pub mod Earth {
29     pub mod Sea {
30         pub (in crate::Earth) struct Shark; // ok!
31     }
32 }
33
34 fn main() {}
35 ```