Skip to content

Update no_std to use the attribute template #1913

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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

ehuss added 8 commits June 27, 2025 14:47
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
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Jun 30, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants