Skip to content

Commit 51eeabf

Browse files
committed
Auto merge of #73562 - poliorcetics:e0432-to-edition2018, r=GuillaumeGomez
Update E0432 long description with the separate behaviors of editions 2015 and 2018 Fixes #64668. I restarted from the work done in #71413.
2 parents 70f9d23 + 5970136 commit 51eeabf

File tree

1 file changed

+25
-10
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+25
-10
lines changed

src/librustc_error_codes/error_codes/E0432.md

+25-10
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,42 @@ Erroneous code example:
66
use something::Foo; // error: unresolved import `something::Foo`.
77
```
88

9-
Paths in `use` statements are relative to the crate root. To import items
10-
relative to the current and parent modules, use the `self::` and `super::`
11-
prefixes, respectively. Also verify that you didn't misspell the import
12-
name and that the import exists in the module from where you tried to
13-
import it. Example:
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:
1420

1521
```
16-
use self::something::Foo; // ok!
22+
use self::something::Foo; // Ok.
1723
1824
mod something {
1925
pub struct Foo;
2026
}
2127
# fn main() {}
2228
```
2329

24-
Or, if you tried to use a module from an external crate, you may have missed
25-
the `extern crate` declaration (which is usually placed in the crate root):
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):
2633

27-
```
28-
extern crate core; // Required to use the `core` crate
34+
```edition2015
35+
extern crate core; // Required to use the `core` crate in Rust 2015.
2936
3037
use core::any;
3138
# fn main() {}
3239
```
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+
```

0 commit comments

Comments
 (0)