Skip to content

Commit d20b406

Browse files
committed
diagnostics for E0432: imports are relative to crate root
This is curiously missing from both the short message and this long diagnostic. Refs #31573 (not sure if it should be considered "fixed" as the short message still only refers to extern crates).
1 parent 2a815a2 commit d20b406

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc_resolve/diagnostics.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -916,19 +916,22 @@ An import was unresolved. Erroneous code example:
916916
use something::Foo; // error: unresolved import `something::Foo`.
917917
```
918918
919-
Please verify you didn't misspell the import name or the import does exist
920-
in the module from where you tried to import it. Example:
919+
Paths in `use` statements are relative to the crate root. To import items
920+
relative to the current and parent modules, use the `self::` and `super::`
921+
prefixes, respectively. Also verify that you didn't misspell the import
922+
name and that the import exists in the module from where you tried to
923+
import it. Example:
921924
922925
```ignore
923-
use something::Foo; // ok!
926+
use self::something::Foo; // ok!
924927
925928
mod something {
926929
pub struct Foo;
927930
}
928931
```
929932
930933
Or, if you tried to use a module from an external crate, you may have missed
931-
the `extern crate` declaration:
934+
the `extern crate` declaration (which is usually placed in the crate root):
932935
933936
```ignore
934937
extern crate homura; // Required to use the `homura` crate

0 commit comments

Comments
 (0)