]> git.lizzy.rs Git - rust.git/commitdiff
E0583: Include secondary path in error message
authorDeadbeef <ent3rm4n@gmail.com>
Wed, 5 May 2021 08:00:18 +0000 (16:00 +0800)
committerDeadbeef <fee1-dead-beef@protonmail.com>
Thu, 6 May 2021 01:40:05 +0000 (09:40 +0800)
compiler/rustc_expand/src/module.rs
src/test/ui/error-codes/E0583.stderr
src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr
src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr
src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr
src/test/ui/parser/mod_file_not_exist.stderr
src/test/ui/parser/mod_file_not_exist_windows.stderr
src/test/ui/parser/unsafe-mod.stderr
src/test/ui/rfc-2457/mod_file_nonascii_forbidden.stderr

index 993522d01d86744bec64592c31f698d58a0e7ae2..4d777049f0d627614d9d322fa7b47d0f175c7753 100644 (file)
@@ -36,7 +36,7 @@ pub struct ModulePathSuccess {
 pub enum ModError<'a> {
     CircularInclusion(Vec<PathBuf>),
     ModInBlock(Option<Ident>),
-    FileNotFound(Ident, PathBuf),
+    FileNotFound(Ident, PathBuf, PathBuf),
     MultipleCandidates(Ident, PathBuf, PathBuf),
     ParserError(DiagnosticBuilder<'a>),
 }
@@ -219,7 +219,7 @@ pub fn default_submod_path<'a>(
             file_path: secondary_path,
             dir_ownership: DirOwnership::Owned { relative: None },
         }),
-        (false, false) => Err(ModError::FileNotFound(ident, default_path)),
+        (false, false) => Err(ModError::FileNotFound(ident, default_path, secondary_path)),
         (true, true) => Err(ModError::MultipleCandidates(ident, default_path, secondary_path)),
     }
 }
@@ -247,7 +247,7 @@ fn report(self, sess: &Session, span: Span) {
                 }
                 err
             }
-            ModError::FileNotFound(ident, default_path) => {
+            ModError::FileNotFound(ident, default_path, secondary_path) => {
                 let mut err = struct_span_err!(
                     diag,
                     span,
@@ -256,9 +256,10 @@ fn report(self, sess: &Session, span: Span) {
                     ident,
                 );
                 err.help(&format!(
-                    "to create the module `{}`, create file \"{}\"",
+                    "to create the module `{}`, create file \"{}\" or \"{}\"",
                     ident,
                     default_path.display(),
+                    secondary_path.display(),
                 ));
                 err
             }
index dbe700355957b1ebe76edff13adb9d7108211fca..c7bbbf114997d36b612fa344abc1b1a8f7c87ded 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/module_that_doesnt_exist.rs" or "$DIR/module_that_doesnt_exist/mod.rs"
 
 error: aborting due to previous error
 
index 52296042eb4a73b80b129fdda944822d3ee7e1cd..7bc8efd7e4a97ee2cdde8a50e7d015d6968f50da 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs"
 
 error: aborting due to previous error
 
index 91b3fe15c4be7a87a4b8525988378e29831eb974..31e4206a5463abeafc3656b63a5dc6cddbe959b8 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/foo/missing.rs" or "$DIR/foo/missing/mod.rs"
 
 error: aborting due to previous error
 
index f519de46c767f9627419778a00845c35a4750ab1..9d252398b7a14bf0d492678bfa82da2f75ea9442 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/foo_inline/inline/missing.rs" or "$DIR/foo_inline/inline/missing/mod.rs"
 
 error: aborting due to previous error
 
index 4e08125625f0a2f15ecd8e48d1e57deeec2f1925..62456d518804feb0646358d5412a88b90d79f970 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/not_a_real_file.rs" or "$DIR/not_a_real_file/mod.rs"
 
 error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
   --> $DIR/mod_file_not_exist.rs:7:16
index 73cdf098b00c96adf29a6c03321e4c3b5c2fd480..d5143dbe982ae28703b94d9f45a9e72166e7df79 100644 (file)
@@ -4,7 +4,7 @@ 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`, create file "$DIR/not_a_real_file.rs" or "$DIR/not_a_real_file/mod.rs"
 
 error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
   --> $DIR/mod_file_not_exist_windows.rs:7:16
index 259b2c1d61e08f865dc856682daf10e0d9f36330..dac6e7a3550567f89fcf5241381d2519ca84448d 100644 (file)
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `n`
 LL | unsafe mod n;
    | ^^^^^^^^^^^^^
    |
-   = help: to create the module `n`, create file "$DIR/n.rs"
+   = help: to create the module `n`, create file "$DIR/n.rs" or "$DIR/n/mod.rs"
 
 error: module cannot be declared unsafe
   --> $DIR/unsafe-mod.rs:1:1
index e857a1e60e5fefb4be8b315bbaf99f982521764f..dd0dac95e36463f412007a7e1a0fb170137b2882 100644 (file)
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `řųśť`
 LL | mod řųśť;
    | ^^^^^^^^^
    |
-   = help: to create the module `řųśť`, create file "$DIR/řųśť.rs"
+   = help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs"
 
 error[E0754]: trying to load file for module `řųśť` with non-ascii identifier name
   --> $DIR/mod_file_nonascii_forbidden.rs:1:5