rust-lang / rust-lang/rust

no_std entrypoint diagnostic suggests invalid `#[no_mangle]` syntax in Edition 2024

Open Beginner friendly
#160,052 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![no_std]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! { loop {} }

fn main() {}
Current output
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]`

error: aborting due to 1 previous error
Desired output
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 `#[unsafe(no_mangle)]`

error: aborting due to 1 previous error
Rationale and extra context

In Edition 2024, the no_mangle attribute must be written using the unsafe-attribute syntax:
#[unsafe(no_mangle)]

The current diagnostic therefore suggests syntax that is rejected under the edition being compiled.

I compiled with:

rustc --edition=2024 -C panic=abort repro.rs

#[unsafe(no_mangle)] is also supported in earlier editions, so the diagnostic should be able to use this spelling unconditionally rather than branching based on the crate edition.

Other cases

Rust Version
$ rustc --version --verbose
rustc 1.97.1 (8bab26f4f 2026-07-14)
binary: rustc
commit-hash: 8bab26f4f68e0e26f0bb7960be334d5b520ea452
commit-date: 2026-07-14
host: x86_64-pc-windows-msvc
release: 1.97.1
LLVM version: 22.1.6
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided rustc command and locating the compiler diagnostic that emits the no_std entrypoint help text. Update the suggested attribute spelling and add or adjust regression coverage so the Edition 2024 output uses valid syntax while preserving the existing diagnostic context.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.