From c85a8fb709105c63e91113a55118538243494243 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 28 May 2017 08:28:21 -0600 Subject: [PATCH] Add note regarding parent module containing use statement. --- src/librustc_resolve/diagnostics.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 368fb7a88685..fa6ea9dba43c 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -838,6 +838,32 @@ trait Foo { fn foo(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##"