]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0432.md
Auto merge of #74124 - ehuss:fix-doc-dry-run-up-to-date, r=Mark-Simulacrum
[rust.git] / src / librustc_error_codes / error_codes / E0432.md
1 An import was unresolved.
2
3 Erroneous code example:
4
5 ```compile_fail,E0432
6 use something::Foo; // error: unresolved import `something::Foo`.
7 ```
8
9 In Rust 2015, paths in `use` statements are relative to the crate root. To
10 import items relative to the current and parent modules, use the `self::` and
11 `super::` prefixes, respectively.
12
13 In Rust 2018, paths in `use` statements are relative to the current module
14 unless they begin with the name of a crate or a literal `crate::`, in which
15 case they start from the crate root. As in Rust 2015 code, the `self::` and
16 `super::` prefixes refer to the current and parent modules respectively.
17
18 Also verify that you didn't misspell the import name and that the import exists
19 in the module from where you tried to import it. Example:
20
21 ```
22 use self::something::Foo; // Ok.
23
24 mod something {
25     pub struct Foo;
26 }
27 # fn main() {}
28 ```
29
30 If you tried to use a module from an external crate and are using Rust 2015,
31 you may have missed the `extern crate` declaration (which is usually placed in
32 the crate root):
33
34 ```edition2015
35 extern crate core; // Required to use the `core` crate in Rust 2015.
36
37 use core::any;
38 # fn main() {}
39 ```
40
41 In Rust 2018 the `extern crate` declaration is not required and you can instead
42 just `use` it:
43
44 ```edition2018
45 use core::any; // No extern crate required in Rust 2018.
46 # fn main() {}
47 ```