-
Notifications
You must be signed in to change notification settings - Fork 563
Reflect explicit macro import in reference #2077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Reflect explicit macro import in reference #2077
Conversation
We put line breaks after our rule identifiers. For new text, or text that would have to be rewrapped, we unwrap the lines. Let's do that here.
| [`macro_use` attribute] pulling in all macros exported from `std` into the | ||
| [`macro_use` prelude]. Both [`core`] and [`std`] are added to the [extern | ||
| prelude]. | ||
| By default, the standard library is automatically included in the crate root module. The [`std`] crate is added to the root. Both [`core`] and [`std`] are added to the [extern prelude]. Standard library macros are imported via [use declarations] and are *not* part of the [`macro_use` prelude]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [
std] crate is added to the root.
Is this sentence needed? I.e., is there any sense in which "the std crate is added to the root" but the core crate is not, or that this is not covered by "Both [core] and [std] are added to the [extern prelude]"?
My reading of the old text is that the sentence was there to support the restrictive clause (that erroneously was preceded by a comma, making the clause seem non-restrictive, i.e. that the part before the comma could stand on its own without the part after it):
The [
std] crate is added to the root, along with an implicit [macro_useattribute] pulling in all macros exported fromstdinto the [macro_useprelude].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, maybe this language and the line below
It does three things... Injects the [
core] crate into the crate root instead of [std].
are leftovers from Rust 2015.
In Rust 2018 and later, this is a valid library:;
use ::core as c1;
use ::std as c2;But it's not in Rust 2015. It gives the error
error[E0432]: unresolved import `core`
--> src/lib.rs:1:5
|
1 | use ::core as c1;
| ^^^^^^^^^^^^ no `core` in the root
unless #![no_std] is used, in which case it accepts that line but not use ::std. Interestingly, I don't see this documented specifically in the 2018 edition guide:
https://doc.rust-lang.org/nightly/edition-guide/rust-2018/path-changes.html
Perhaps this is simply an artifact of the change to make crates in the extern prelude accessible to use declarations. Did that then make it fully unobservable whether core is separately added to the crate root or not, or is there still some way to tell?
cc @ehuss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking, this is all covered in:
I'm going to go get that merged.
Companion PR for rust-lang/rust#139493