Suggest #[unsafe(no_mangle)] for entry points in no_std binaries - #163559
Merged
Merged
Conversation
Collaborator
|
Thanks for the pull request, and welcome! The Rust Project has assigned @tiif (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
nnethercote
approved these changes
Sep 30, 2026
Contributor
|
Thanks for the fix! @bors r+ rollup |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Rollup of 20 pull requests Successful merges: - #163279 (const and NonZero impl for clamp_magnitude()) - #163081 (Provide more context on "not general enough" error) - #163455 (Don't use the metadata based crate_hash for rustdoc runs) - #159798 (Attribute documentation for cfg_attr) - #162921 (make mips64 `Complex` GCC-compatible) - #163368 (Don't build format string suggestions from `concat!` offsets) - #163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance) - #163470 (Miscellaneous attr error stuff) - #163489 (expose Rc::is_unique) - #163492 (x86 and x86_64: cleanup some callconv code) - #163496 (cycle handling: mirror old solver) - #163509 (Use more default field values in `Resolver`) - #163519 (Forbid `Reborrow` impls for types with destructors) - #163520 (Cast cleanups) - #163524 (Document `Result` case for the `arena_cache` query modifier) - #163546 (PassWrapper: adapt for new PassPlugin load method) - #163551 (Add libs-nominated triagebot config) - #163559 (Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries) - #163564 (rustc-dev-guide subtree update) - #163568 (remove dead cfg_select! arm)
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Rollup merge of #163559 - simonether:no-std-no-mangle-help, r=nnethercote Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries Fixes #160052 The help for "using `fn main` requires the standard library" told users to declare their own entry point with `#[no_mangle]`, which is an error in edition 2024. It now suggests `#[unsafe(no_mangle)]`. rustc has accepted that form in every edition since 1.82 (#128771), so the help does not need to depend on the edition. The help keeps the bracketed form rather than naming the attribute in words (mejrs's suggestion), because it shows text the user writes verbatim. This follows [nnethercote's comment](#160052 (comment)), and `rustc_lint` already does the same ([diagnostics.rs](https://github.com/rust-lang/rust/blob/1625626af12c1f95540530c6fc1242ff10aaba0a/compiler/rustc_lint/src/diagnostics.rs#L950)). I updated the expected output of the UI test, and tidy passes. I have not built the compiler locally, so the UI test will first run in CI.
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Oct 1, 2026
Rollup of 20 pull requests Successful merges: - rust-lang/rust#163279 (const and NonZero impl for clamp_magnitude()) - rust-lang/rust#163081 (Provide more context on "not general enough" error) - rust-lang/rust#163455 (Don't use the metadata based crate_hash for rustdoc runs) - rust-lang/rust#159798 (Attribute documentation for cfg_attr) - rust-lang/rust#162921 (make mips64 `Complex` GCC-compatible) - rust-lang/rust#163368 (Don't build format string suggestions from `concat!` offsets) - rust-lang/rust#163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance) - rust-lang/rust#163470 (Miscellaneous attr error stuff) - rust-lang/rust#163489 (expose Rc::is_unique) - rust-lang/rust#163492 (x86 and x86_64: cleanup some callconv code) - rust-lang/rust#163496 (cycle handling: mirror old solver) - rust-lang/rust#163509 (Use more default field values in `Resolver`) - rust-lang/rust#163519 (Forbid `Reborrow` impls for types with destructors) - rust-lang/rust#163520 (Cast cleanups) - rust-lang/rust#163524 (Document `Result` case for the `arena_cache` query modifier) - rust-lang/rust#163546 (PassWrapper: adapt for new PassPlugin load method) - rust-lang/rust#163551 (Add libs-nominated triagebot config) - rust-lang/rust#163559 (Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries) - rust-lang/rust#163564 (rustc-dev-guide subtree update) - rust-lang/rust#163568 (remove dead cfg_select! arm)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #160052
The help for "using
fn mainrequires the standard library" told users to declare their own entry point with#[no_mangle], which is an error in edition 2024. It now suggests#[unsafe(no_mangle)]. rustc has accepted that form in every edition since 1.82 (#128771), so the help does not need to depend on the edition.The help keeps the bracketed form rather than naming the attribute in words (mejrs's suggestion), because it shows text the user writes verbatim. This follows nnethercote's comment, and
rustc_lintalready does the same (diagnostics.rs).I updated the expected output of the UI test, and tidy passes. I have not built the compiler locally, so the UI test will first run in CI.
cc @mejrs @nnethercote