diff --git a/src/librustc_expand/module.rs b/src/librustc_expand/module.rs index aad92a09743b3..70c9bbdb9b3f5 100644 --- a/src/librustc_expand/module.rs +++ b/src/librustc_expand/module.rs @@ -280,10 +280,14 @@ pub fn default_submod_path<'a>( mod_name, ); err.help(&format!( - "to create the module `{}`, create file \"{}\"", + "to create the module `{}` here, create file \"{}\"", mod_name, default_path.display(), )); + err.help(&format!( + "if there is `mod {}` elsewhere in the crate already, import it with `use crate::` instead", + mod_name, + )); Err(err) } (true, true) => { diff --git a/src/test/ui/error-codes/E0583.stderr b/src/test/ui/error-codes/E0583.stderr index dbe700355957b..d6917bb48a356 100644 --- a/src/test/ui/error-codes/E0583.stderr +++ b/src/test/ui/error-codes/E0583.stderr @@ -4,7 +4,8 @@ error[E0583]: file not found for module `module_that_doesnt_exist` LL | mod module_that_doesnt_exist; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: to create the module `module_that_doesnt_exist`, create file "$DIR/module_that_doesnt_exist.rs" + = help: to create the module `module_that_doesnt_exist` here, create file "$DIR/module_that_doesnt_exist.rs" + = help: if there is `mod module_that_doesnt_exist` elsewhere in the crate already, import it with `use crate::` instead error: aborting due to previous error diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr b/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr index 52296042eb4a7..6d3d4475c2b82 100644 --- a/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr +++ b/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr @@ -4,7 +4,8 @@ error[E0583]: file not found for module `baz` LL | pub mod baz; | ^^^^^^^^^^^^ | - = help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" + = help: to create the module `baz` here, create file "$DIR/auxiliary/foo/bar/baz.rs" + = help: if there is `mod baz` elsewhere in the crate already, import it with `use crate::` instead error: aborting due to previous error diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr index 91b3fe15c4be7..b31db9b58c686 100644 --- a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr @@ -4,7 +4,8 @@ error[E0583]: file not found for module `missing` LL | mod missing; | ^^^^^^^^^^^^ | - = help: to create the module `missing`, create file "$DIR/foo/missing.rs" + = help: to create the module `missing` here, create file "$DIR/foo/missing.rs" + = help: if there is `mod missing` elsewhere in the crate already, import it with `use crate::` instead error: aborting due to previous error diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr index f519de46c767f..e53049091094b 100644 --- a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr @@ -4,7 +4,8 @@ error[E0583]: file not found for module `missing` LL | mod missing; | ^^^^^^^^^^^^ | - = help: to create the module `missing`, create file "$DIR/foo_inline/inline/missing.rs" + = help: to create the module `missing` here, create file "$DIR/foo_inline/inline/missing.rs" + = help: if there is `mod missing` elsewhere in the crate already, import it with `use crate::` instead error: aborting due to previous error diff --git a/src/test/ui/parser/mod_file_not_exist.rs b/src/test/ui/parser/mod_file_not_exist.rs index f4a27b52ec5b4..65775d99a47f4 100644 --- a/src/test/ui/parser/mod_file_not_exist.rs +++ b/src/test/ui/parser/mod_file_not_exist.rs @@ -1,7 +1,8 @@ // ignore-windows mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` -//~^ HELP to create the module `not_a_real_file`, create file +//~^ HELP to create the module `not_a_real_file` here, create file +//~| HELP if there is `mod not_a_real_file` elsewhere in the crate already fn main() { assert_eq!(mod_file_aux::bar(), 10); diff --git a/src/test/ui/parser/mod_file_not_exist.stderr b/src/test/ui/parser/mod_file_not_exist.stderr index 087ae9fe3e016..76ea04c3dd8ea 100644 --- a/src/test/ui/parser/mod_file_not_exist.stderr +++ b/src/test/ui/parser/mod_file_not_exist.stderr @@ -4,10 +4,11 @@ error[E0583]: file not found for module `not_a_real_file` LL | mod not_a_real_file; | ^^^^^^^^^^^^^^^^^^^^ | - = help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs" + = help: to create the module `not_a_real_file` here, create file "$DIR/not_a_real_file.rs" + = help: if there is `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::` instead error[E0433]: failed to resolve: use of undeclared type or module `mod_file_aux` - --> $DIR/mod_file_not_exist.rs:7:16 + --> $DIR/mod_file_not_exist.rs:8:16 | LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of undeclared type or module `mod_file_aux` diff --git a/src/test/ui/parser/mod_file_not_exist_windows.rs b/src/test/ui/parser/mod_file_not_exist_windows.rs index 4b7d7a02bbe78..9f5bad107809f 100644 --- a/src/test/ui/parser/mod_file_not_exist_windows.rs +++ b/src/test/ui/parser/mod_file_not_exist_windows.rs @@ -1,7 +1,8 @@ // only-windows mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` -//~^ HELP to create the module `not_a_real_file`, create file +//~^ HELP to create the module `not_a_real_file` here, create file +//~^ HELP if there is `mod not_a_real_file` elsewhere in the crate already fn main() { assert_eq!(mod_file_aux::bar(), 10); diff --git a/src/test/ui/parser/mod_file_not_exist_windows.stderr b/src/test/ui/parser/mod_file_not_exist_windows.stderr index d67205cfdf100..646bb05572916 100644 --- a/src/test/ui/parser/mod_file_not_exist_windows.stderr +++ b/src/test/ui/parser/mod_file_not_exist_windows.stderr @@ -4,7 +4,8 @@ error[E0583]: file not found for module `not_a_real_file` LL | mod not_a_real_file; | ^^^^^^^^^^^^^^^^^^^^ | - = help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs" + = help: to create the module `not_a_real_file` here, create file "$DIR/not_a_real_file.rs" + = help: if there is `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::` instead error[E0433]: failed to resolve: use of undeclared type or module `mod_file_aux` --> $DIR/mod_file_not_exist_windows.rs:7:16