Skip to content

Conversation

@ehuss
Copy link
Contributor

@ehuss ehuss commented Jun 30, 2025

New rules:

  • names.preludes.extern.no_std.syntax
  • names.preludes.extern.no_std.duplicates
  • names.preludes.extern.no_std.edition2018

Renamed rules:

  • names.preludes.extern.no_std.extern and names.preludes.extern.no_std.core is now names.preludes.extern.no_std.inject

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Jun 30, 2025
ehuss and others added 11 commits November 11, 2025 22:40
These don't really belong where they are, and are just generally helpful
things about the attribute.
The current text was a little bit of a mess and had some subtle
inaccuracies. This reworks so that the intro follows the template, and
just generally introduces the attribute.

`allowed-positions` now just specifies the allowed positions.

I reworked the behavior changes caused by no_std into proper separate
rules.

`std` is not injected into the crate root anymore starting with edition
2018.
I do not know how this was missing, I've looked at it a million times. I
feel like I was maybe missing something, but I really can't find
anything that directly refers to this, nor can I find any open issues.

I believe this is now done with this relatively subtle bit:
https://github.com/rust-lang/rust/blob/4d08223c054cf5a56d9761ca925fd46ffebe7115/compiler/rustc_builtin_macros/src/standard_library_imports.rs#L42

In the past it used to use a different approach of emulating `extern crate std as _;`:
https://github.com/rust-lang/rust/blob/c8cf9f5a025bb475804b5a90f54aca310b952526/src/libsyntax_ext/standard_library_imports.rs#L42-L46
More closely align with the template, and some minor word tweaks.
We had said here that the `no_std` attribute is used to "prevent the
automatic linking of the std crate", but then further down we say,
"using `no_std` does not prevent the standard library from being
linked in".

The important distinction here is the word "automatically", but that
gets a bit lost due to reusing the "prevent" phrasing.

Probably "prevent" is just too strong a word to use when what we're
really saying is that we're causing something to not happen
automatically.  Let's make that more clear and increase sentence
parallelism.
Some sentences here could be improved with more sentence parallelism
and a bit of reordering, so let's do that.
@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

We had text in the intro about "deferring to the core crate instead",
but it may not have been sufficiently clear what we mean exactly by
that.  Let's talk specifically about how `no_std` causes us to use the
`core` crate for the standard library prelude and for the `macro_use`
prelude.
We want to highlight how using `no_std` doesn't prevent `std` from
being linked.  Let's revise and elaborate this text for clarity.
The text here could be read in such a way as to imply that `no_std`
affected whether or not `core` was added to the extern prelude, but
that isn't the case.  Let's make it clear that this section is about
what is added to the `macro_use` prelude and speak to that directly.
@traviscross traviscross added this pull request to the merge queue Nov 11, 2025
Merged via the queue into rust-lang:master with commit bbb5cc6 Nov 11, 2025
5 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants