Skip to content

Commit 208af20

Browse files
Add long error explanation for E0740
1 parent c8420db commit 208af20

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/librustc_resolve/error_codes.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,44 @@ struct Foo<X = Box<Self>> {
19331933
```
19341934
"##,
19351935

1936+
E0741: r##"
1937+
Visibility is restricted to a module which isn't an ancestor of the current
1938+
item.
1939+
1940+
Erroneous code example:
1941+
1942+
```compile_fail,E0741,edition2018
1943+
pub mod Sea {}
1944+
1945+
pub (in crate::Sea) struct Shark; // error!
1946+
1947+
fn main() {}
1948+
```
1949+
1950+
To fix this error, we need to move the `Shark` struct inside the `Sea` module:
1951+
1952+
```edition2018
1953+
pub mod Sea {
1954+
pub (in crate::Sea) struct Shark; // ok!
1955+
}
1956+
1957+
fn main() {}
1958+
```
1959+
1960+
Of course, you can do it as long as the module you're referring to is an
1961+
ancestor:
1962+
1963+
```edition2018
1964+
pub mod Earth {
1965+
pub mod Sea {
1966+
pub (in crate::Earth) struct Shark; // ok!
1967+
}
1968+
}
1969+
1970+
fn main() {}
1971+
```
1972+
"##,
1973+
19361974
;
19371975
// E0153, unused error code
19381976
// E0157, unused error code
@@ -1953,5 +1991,4 @@ struct Foo<X = Box<Self>> {
19531991
// E0470, removed
19541992
E0577,
19551993
E0578,
1956-
E0740,
19571994
}

0 commit comments

Comments
 (0)