Skip to content

Commit b39024d

Browse files
authored
Rollup merge of rust-lang#84945 - fee1-dead:E0583-better-message, r=petrochenkov
E0583: Include secondary path in error message Fixes rust-lang#84819.
2 parents 796b745 + 4617b03 commit b39024d

File tree

9 files changed

+13
-12
lines changed

9 files changed

+13
-12
lines changed

compiler/rustc_expand/src/module.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ crate struct ParsedExternalMod {
3636
pub enum ModError<'a> {
3737
CircularInclusion(Vec<PathBuf>),
3838
ModInBlock(Option<Ident>),
39-
FileNotFound(Ident, PathBuf),
39+
FileNotFound(Ident, PathBuf, PathBuf),
4040
MultipleCandidates(Ident, PathBuf, PathBuf),
4141
ParserError(DiagnosticBuilder<'a>),
4242
}
@@ -219,7 +219,7 @@ pub fn default_submod_path<'a>(
219219
file_path: secondary_path,
220220
dir_ownership: DirOwnership::Owned { relative: None },
221221
}),
222-
(false, false) => Err(ModError::FileNotFound(ident, default_path)),
222+
(false, false) => Err(ModError::FileNotFound(ident, default_path, secondary_path)),
223223
(true, true) => Err(ModError::MultipleCandidates(ident, default_path, secondary_path)),
224224
}
225225
}
@@ -247,7 +247,7 @@ impl ModError<'_> {
247247
}
248248
err
249249
}
250-
ModError::FileNotFound(ident, default_path) => {
250+
ModError::FileNotFound(ident, default_path, secondary_path) => {
251251
let mut err = struct_span_err!(
252252
diag,
253253
span,
@@ -256,9 +256,10 @@ impl ModError<'_> {
256256
ident,
257257
);
258258
err.help(&format!(
259-
"to create the module `{}`, create file \"{}\"",
259+
"to create the module `{}`, create file \"{}\" or \"{}\"",
260260
ident,
261261
default_path.display(),
262+
secondary_path.display(),
262263
));
263264
err
264265
}

src/test/ui/error-codes/E0583.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `module_that_doesnt_exist`
44
LL | mod module_that_doesnt_exist;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: to create the module `module_that_doesnt_exist`, create file "$DIR/module_that_doesnt_exist.rs"
7+
= 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"
88

99
error: aborting due to previous error
1010

src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `baz`
44
LL | pub mod baz;
55
| ^^^^^^^^^^^^
66
|
7-
= help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs"
7+
= help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs"
88

99
error: aborting due to previous error
1010

src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `missing`
44
LL | mod missing;
55
| ^^^^^^^^^^^^
66
|
7-
= help: to create the module `missing`, create file "$DIR/foo/missing.rs"
7+
= help: to create the module `missing`, create file "$DIR/foo/missing.rs" or "$DIR/foo/missing/mod.rs"
88

99
error: aborting due to previous error
1010

src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `missing`
44
LL | mod missing;
55
| ^^^^^^^^^^^^
66
|
7-
= help: to create the module `missing`, create file "$DIR/foo_inline/inline/missing.rs"
7+
= help: to create the module `missing`, create file "$DIR/foo_inline/inline/missing.rs" or "$DIR/foo_inline/inline/missing/mod.rs"
88

99
error: aborting due to previous error
1010

src/test/ui/parser/mod_file_not_exist.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `not_a_real_file`
44
LL | mod not_a_real_file;
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs"
7+
= 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"
88

99
error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
1010
--> $DIR/mod_file_not_exist.rs:7:16

src/test/ui/parser/mod_file_not_exist_windows.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `not_a_real_file`
44
LL | mod not_a_real_file;
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: to create the module `not_a_real_file`, create file "$DIR/not_a_real_file.rs"
7+
= 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"
88

99
error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
1010
--> $DIR/mod_file_not_exist_windows.rs:7:16

src/test/ui/parser/unsafe-mod.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `n`
44
LL | unsafe mod n;
55
| ^^^^^^^^^^^^^
66
|
7-
= help: to create the module `n`, create file "$DIR/n.rs"
7+
= help: to create the module `n`, create file "$DIR/n.rs" or "$DIR/n/mod.rs"
88

99
error: module cannot be declared unsafe
1010
--> $DIR/unsafe-mod.rs:1:1

src/test/ui/rfc-2457/mod_file_nonascii_forbidden.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0583]: file not found for module `řųśť`
44
LL | mod řųśť;
55
| ^^^^^^^^^
66
|
7-
= help: to create the module `řųśť`, create file "$DIR/řųśť.rs"
7+
= help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs"
88

99
error[E0754]: trying to load file for module `řųśť` with non-ascii identifier name
1010
--> $DIR/mod_file_nonascii_forbidden.rs:1:5

0 commit comments

Comments
 (0)