Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention the syntax for use on mod foo; if foo doesn't exist #116992

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_expand/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ expand_module_circular =
expand_module_file_not_found =
file not found for module `{$name}`
.help = to create the module `{$name}`, create file "{$default_path}" or "{$secondary_path}"
.note = if there is a `mod {$name}` elsewhere in the crate already, import it with `use crate::...` instead

expand_module_in_block =
cannot declare a non-inline module inside a block unless it has a path attribute
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ pub(crate) struct ModuleInBlockName {
#[derive(Diagnostic)]
#[diag(expand_module_file_not_found, code = "E0583")]
#[help]
#[note]
pub(crate) struct ModuleFileNotFound {
#[primary_span]
pub span: Span,
Expand Down
1 change: 1 addition & 0 deletions tests/run-make/unknown-mod-stdin/unknown-mod.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ error[E0583]: file not found for module `unknown`
| ^^^^^^^^^^^^
|
= help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs"
= note: if there is a `mod unknown` elsewhere in the crate already, import it with `use crate::...` instead

error: aborting due to previous error

Expand Down
1 change: 1 addition & 0 deletions tests/ui/error-codes/E0583.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod module_that_doesnt_exist;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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"
= note: if there is a `mod module_that_doesnt_exist` elsewhere in the crate already, import it with `use crate::...` instead

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | pub mod baz;
| ^^^^^^^^^^^^
|
= help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs"
= note: if there is a `mod baz` elsewhere in the crate already, import it with `use crate::...` instead

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod missing;
| ^^^^^^^^^^^^
|
= help: to create the module `missing`, create file "$DIR/foo/missing.rs" or "$DIR/foo/missing/mod.rs"
= note: if there is a `mod missing` elsewhere in the crate already, import it with `use crate::...` instead

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod missing;
| ^^^^^^^^^^^^
|
= help: to create the module `missing`, create file "$DIR/foo_inline/inline/missing.rs" or "$DIR/foo_inline/inline/missing/mod.rs"
= note: if there is a `mod missing` elsewhere in the crate already, import it with `use crate::...` instead

error: aborting due to previous error

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/modules/special_module_name.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod lib;
| ^^^^^^^^
|
= help: to create the module `lib`, create file "$DIR/lib.rs" or "$DIR/lib/mod.rs"
= note: if there is a `mod lib` elsewhere in the crate already, import it with `use crate::...` instead

error[E0583]: file not found for module `main`
--> $DIR/special_module_name.rs:4:1
Expand All @@ -13,6 +14,7 @@ LL | mod main;
| ^^^^^^^^^
|
= help: to create the module `main`, create file "$DIR/main.rs" or "$DIR/main/mod.rs"
= note: if there is a `mod main` elsewhere in the crate already, import it with `use crate::...` instead

warning: found module declaration for lib.rs
--> $DIR/special_module_name.rs:1:1
Expand Down
1 change: 1 addition & 0 deletions tests/ui/parser/mod_file_not_exist.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod not_a_real_file;
| ^^^^^^^^^^^^^^^^^^^^
|
= 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"
= note: if there is a `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::...` instead

error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
--> $DIR/mod_file_not_exist.rs:7:16
Expand Down
1 change: 1 addition & 0 deletions tests/ui/parser/mod_file_not_exist_windows.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod not_a_real_file;
| ^^^^^^^^^^^^^^^^^^^^
|
= 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"
= note: if there is a `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::...` instead

error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
--> $DIR/mod_file_not_exist_windows.rs:7:16
Expand Down
1 change: 1 addition & 0 deletions tests/ui/parser/unsafe-mod.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | unsafe mod n;
| ^^^^^^^^^^^^^
|
= help: to create the module `n`, create file "$DIR/n.rs" or "$DIR/n/mod.rs"
= note: if there is a `mod n` elsewhere in the crate already, import it with `use crate::...` instead

error: module cannot be declared unsafe
--> $DIR/unsafe-mod.rs:1:1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | mod řųśť;
| ^^^^^^^^^
|
= help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs"
= note: if there is a `mod řųśť` elsewhere in the crate already, import it with `use crate::...` instead

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