about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-05-30 05:01:10 +0000
committerbors <bors@rust-lang.org>2017-05-30 05:01:10 +0000
commite1fe1a8933c5d13da9fcde618c074c0d4e099b96 (patch)
tree17d24e19f43340fbe806b337050fb319a7f3f6b8 /src
parent77d096a2bb3f914f33a5daf10bfe855d0011e57e (diff)
parentc85a8fb709105c63e91113a55118538243494243 (diff)
downloadrust-e1fe1a8933c5d13da9fcde618c074c0d4e099b96.tar.gz
rust-e1fe1a8933c5d13da9fcde618c074c0d4e099b96.zip
Auto merge of #42283 - Mark-Simulacrum:issue-40341, r=pnkfelix
Add note regarding parent module containing use statement.

Fixes #40341.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/diagnostics.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 368fb7a8868..fa6ea9dba43 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -838,6 +838,32 @@ trait Foo {
 
 fn foo<T>(x: T) {} // ok!
 ```
+
+Another case that causes this error is when a type is imported into a parent
+module. To fix this, you can follow the suggestion and use File directly or
+`use super::File;` which will import the types from the parent namespace. An
+example that causes this error is below:
+
+```compile_fail,E0412
+use std::fs::File;
+
+mod foo {
+    fn some_function(f: File) {}
+}
+```
+
+```
+use std::fs::File;
+
+mod foo {
+    // either
+    use super::File;
+    // or
+    // use std::fs::File;
+    fn foo(f: File) {}
+}
+# fn main() {} // don't insert it for us; that'll break imports
+```
 "##,
 
 E0415: r##"