Skip to content

Commit e1fe1a8

Browse files
committed
Auto merge of rust-lang#42283 - Mark-Simulacrum:issue-40341, r=pnkfelix
Add note regarding parent module containing use statement. Fixes rust-lang#40341.
2 parents 77d096a + c85a8fb commit e1fe1a8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/librustc_resolve/diagnostics.rs

+26
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,32 @@ trait Foo {
838838
839839
fn foo<T>(x: T) {} // ok!
840840
```
841+
842+
Another case that causes this error is when a type is imported into a parent
843+
module. To fix this, you can follow the suggestion and use File directly or
844+
`use super::File;` which will import the types from the parent namespace. An
845+
example that causes this error is below:
846+
847+
```compile_fail,E0412
848+
use std::fs::File;
849+
850+
mod foo {
851+
fn some_function(f: File) {}
852+
}
853+
```
854+
855+
```
856+
use std::fs::File;
857+
858+
mod foo {
859+
// either
860+
use super::File;
861+
// or
862+
// use std::fs::File;
863+
fn foo(f: File) {}
864+
}
865+
# fn main() {} // don't insert it for us; that'll break imports
866+
```
841867
"##,
842868

843869
E0415: r##"

0 commit comments

Comments
 (0)