mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 01:40:02 +00:00
Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries
Fixes rust-lang/rust#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 (rust-lang/rust#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](https://github.com/rust-lang/rust/issues/160052#issuecomment-5103462837), and `rustc_lint` already does the same ([diagnostics.rs](1625626af1/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.