Skip to content

Commit ad89586

Browse files
committed
Explain extern crate exceptions
Fixes #121
1 parent d5f43bf commit ad89586

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/rust-2018/module-system/path-clarity.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ clear as to what is going on.
1515

1616
Here's a brief summary:
1717

18-
* `extern crate` is no longer needed
18+
* `extern crate` is no longer needed in 99% of circumstances.
1919
* The `crate` keyword refers to the current crate.
2020
* Absolute paths begin with a crate name, where the keyword `crate`
2121
refers to the current crate.
@@ -66,6 +66,32 @@ keep doing what you were doing there as well.
6666
> One small note here: `cargo fix` will not currently automate this change. We may
6767
> have it do this for you in the future.
6868
69+
#### An exception
70+
71+
There's one exception to this rule, and that's the "sysroot" crates. These are the
72+
crates distributed with Rust itself. We'd eventually like to remove the requirement
73+
for `extern crate` for them as well, but it hasn't shipped yet.
74+
75+
You'll need to use `extern crate` for:
76+
77+
* `proc_macro`
78+
79+
Additionally, you would need to use it for:
80+
81+
* `core`
82+
* `std`
83+
84+
However, `extern crate std;` is already implicit, and with `#![no_std]`,
85+
`extern crate core;` is already implicit. You'll only need these in highly
86+
specialized situations.
87+
88+
Finally, on nightly, you'll need it for crates like:
89+
90+
* `alloc`
91+
* `test`
92+
93+
#### Macros
94+
6995
One other use for `extern crate` was to import macros; that's no longer needed.
7096
Check [the macro section](../macros/macro-changes.html) for more.
7197

0 commit comments

Comments
 (0)