Skip to content

Commit 6e82517

Browse files
committed
Documenting the separate behaviors of edition 2015 and 2018
1 parent 033013c commit 6e82517

File tree

1 file changed

+26
-5
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+26
-5
lines changed

src/librustc_error_codes/error_codes/E0432.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,42 @@ prefixes, respectively. Also verify that you didn't misspell the import
1212
name and that the import exists in the module from where you tried to
1313
import it. Example:
1414

15+
In Rust 2015, paths in `use` statements are relative to the crate root. To
16+
import items relative to the current and parent modules, use the `self::` and
17+
`super::` prefixes, respectively.
18+
19+
In Rust 2018, paths in `use` statements are relative to the current module
20+
unless they begin with the name of a crate or a literal `crate::`, in which
21+
case they start from the crate root. As in Rust 2015 code, the `self::` and
22+
`super::` prefixes refer to the current and parent modules respectively.
23+
24+
Also verify that you didn't misspell the import name and that the import exists
25+
in the module from where you tried to import it. Example:
26+
1527
```
16-
use self::something::Foo; // ok!
28+
use self::something::Foo; // Ok.
1729
1830
mod something {
1931
pub struct Foo;
2032
}
2133
# fn main() {}
2234
```
2335

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):
36+
If you tried to use a module from an external crate and are using Rust 2015,
37+
you may have missed the `extern crate` declaration (which is usually placed in
38+
the crate root):
2639

27-
```
28-
extern crate core; // Required to use the `core` crate
40+
```edition2015
41+
extern crate core; // Required to use the `core` crate in Rust 2015.
2942
3043
use core::any;
44+
# fn main() { assert!(false); }
45+
```
46+
47+
In Rust 2018 the `extern crate` declaration is not required and you can instead
48+
just `use` it:
49+
50+
```
51+
use core::any; // No extern crate required in Rust 2018.
3152
# fn main() {}
3253
```

0 commit comments

Comments
 (0)