File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -1897,6 +1897,44 @@ struct Foo<X = Box<Self>> {
1897
1897
```
1898
1898
"## ,
1899
1899
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
+
1900
1938
;
1901
1939
// E0153, unused error code
1902
1940
// E0157, unused error code
@@ -1918,5 +1956,4 @@ struct Foo<X = Box<Self>> {
1918
1956
E0576 ,
1919
1957
E0577 ,
1920
1958
E0578 ,
1921
- E0740 ,
1922
1959
}
You can’t perform that action at this time.
0 commit comments