]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0742.md
Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
[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 ```