Skip to content

Commit 8c08d8a

Browse files
Add long error explanation for E0740
1 parent 0771b89 commit 8c08d8a

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/librustc_resolve/error_codes.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,44 @@ struct Foo<X = Box<Self>> {
18971897
```
18981898
"##,
18991899

1900+
E0741: r##"
1901+
Visibility is restricted to a module which isn't an ancestor of the current
1902+
item.
1903+
1904+
Erroneous code example:
1905+
1906+
```compile_fail,E0741,edition2018
1907+
pub mod Sea {}
1908+
1909+
pub (in crate::Sea) struct Shark; // error!
1910+
1911+
fn main() {}
1912+
```
1913+
1914+
To fix this error, we need to move the `Shark` struct inside the `Sea` module:
1915+
1916+
```edition2018
1917+
pub mod Sea {
1918+
pub (in crate::Sea) struct Shark; // ok!
1919+
}
1920+
1921+
fn main() {}
1922+
```
1923+
1924+
Of course, you can do it as long as the module you're referring to is an
1925+
ancestor:
1926+
1927+
```edition2018
1928+
pub mod Earth {
1929+
pub mod Sea {
1930+
pub (in crate::Earth) struct Shark; // ok!
1931+
}
1932+
}
1933+
1934+
fn main() {}
1935+
```
1936+
"##,
1937+
19001938
;
19011939
// E0153, unused error code
19021940
// E0157, unused error code
@@ -1918,5 +1956,4 @@ struct Foo<X = Box<Self>> {
19181956
E0576,
19191957
E0577,
19201958
E0578,
1921-
E0740,
19221959
}

0 commit comments

Comments
 (0)