Mention the syntax for use
on mod foo;
if foo
doesn't exist
Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`. Fix #69492.
This commit is contained in:
parent
cc705b8012
commit
2cca435717
12 changed files with 13 additions and 0 deletions
|
@ -86,6 +86,7 @@ expand_module_circular =
|
||||||
expand_module_file_not_found =
|
expand_module_file_not_found =
|
||||||
file not found for module `{$name}`
|
file not found for module `{$name}`
|
||||||
.help = to create the module `{$name}`, create file "{$default_path}" or "{$secondary_path}"
|
.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 =
|
expand_module_in_block =
|
||||||
cannot declare a non-inline module inside a block unless it has a path attribute
|
cannot declare a non-inline module inside a block unless it has a path attribute
|
||||||
|
|
|
@ -350,6 +350,7 @@ pub(crate) struct ModuleInBlockName {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_module_file_not_found, code = "E0583")]
|
#[diag(expand_module_file_not_found, code = "E0583")]
|
||||||
#[help]
|
#[help]
|
||||||
|
#[note]
|
||||||
pub(crate) struct ModuleFileNotFound {
|
pub(crate) struct ModuleFileNotFound {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
|
@ -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"
|
= 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -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"
|
= 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -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"
|
= 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -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"
|
= 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -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"
|
= 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | mod lib;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: to create the module `lib`, create file "$DIR/lib.rs" or "$DIR/lib/mod.rs"
|
= 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`
|
error[E0583]: file not found for module `main`
|
||||||
--> $DIR/special_module_name.rs:4:1
|
--> $DIR/special_module_name.rs:4:1
|
||||||
|
@ -13,6 +14,7 @@ LL | mod main;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: to create the module `main`, create file "$DIR/main.rs" or "$DIR/main/mod.rs"
|
= 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
|
warning: found module declaration for lib.rs
|
||||||
--> $DIR/special_module_name.rs:1:1
|
--> $DIR/special_module_name.rs:1:1
|
||||||
|
|
|
@ -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"
|
= 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`
|
error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
|
||||||
--> $DIR/mod_file_not_exist.rs:7:16
|
--> $DIR/mod_file_not_exist.rs:7:16
|
||||||
|
|
|
@ -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"
|
= 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`
|
error[E0433]: failed to resolve: use of undeclared crate or module `mod_file_aux`
|
||||||
--> $DIR/mod_file_not_exist_windows.rs:7:16
|
--> $DIR/mod_file_not_exist_windows.rs:7:16
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | unsafe mod n;
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: to create the module `n`, create file "$DIR/n.rs" or "$DIR/n/mod.rs"
|
= 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
|
error: module cannot be declared unsafe
|
||||||
--> $DIR/unsafe-mod.rs:1:1
|
--> $DIR/unsafe-mod.rs:1:1
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | mod řųśť;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs"
|
= 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
|
error[E0754]: trying to load file for module `řųśť` with non-ascii identifier name
|
||||||
--> $DIR/mod_file_nonascii_forbidden.rs:1:5
|
--> $DIR/mod_file_nonascii_forbidden.rs:1:5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue