From 1eb5c521ce0da5f66a184db06611ff41f7e28a44 Mon Sep 17 00:00:00 2001 From: Simon Sudarushkin <68971770+simonether@users.noreply.github.com> Date: Wed, 30 Sep 2026 21:41:24 +0500 Subject: [PATCH] Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries --- compiler/rustc_monomorphize/src/diagnostics.rs | 2 +- tests/ui/no_std/no-std-no-start-binary.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_monomorphize/src/diagnostics.rs b/compiler/rustc_monomorphize/src/diagnostics.rs index a1930dbea3cda..7635050603c41 100644 --- a/compiler/rustc_monomorphize/src/diagnostics.rs +++ b/compiler/rustc_monomorphize/src/diagnostics.rs @@ -96,7 +96,7 @@ pub(crate) struct EncounteredErrorWhileInstantiatingGlobalAsm { #[derive(Diagnostic)] #[diag("using `fn main` requires the standard library")] #[help( - "use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`" + "use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[unsafe(no_mangle)]`" )] pub(crate) struct StartNotFound; diff --git a/tests/ui/no_std/no-std-no-start-binary.stderr b/tests/ui/no_std/no-std-no-start-binary.stderr index dd06c234da294..bc6ded80ff8fe 100644 --- a/tests/ui/no_std/no-std-no-start-binary.stderr +++ b/tests/ui/no_std/no-std-no-start-binary.stderr @@ -1,6 +1,6 @@ error: using `fn main` requires the standard library | - = help: use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]` + = help: use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[unsafe(no_mangle)]` error: aborting due to 1 previous error