Skip to content

Conversation

@Voultapher
Copy link

Companion PR for rust-lang/rust#139493

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Nov 8, 2025
@traviscross traviscross added the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Nov 9, 2025
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].
Copy link
Contributor

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_use attribute] pulling in all macros exported from std into the [macro_use prelude].

Copy link
Contributor

@traviscross traviscross Nov 9, 2025

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: The marked PR is awaiting review from a maintainer S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants