Unsafe attributes not allowed
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
Summary
While all attributes made unsafe in the 2024 edition can be used without unsafe in prior editions, rustc still accepts the unsafe marking on older editions.
Reproducer
I tried this code:
#[unsafe(no_mangle)]
fn foo() {}
Does the code make use of any (1.49) nightly feature ?
- Nightly
Godbolt link
No response
Actual behavior
An error is emitted.
Expected behavior
Compiles successfully on all editions.
GCC Version
gccrs (Compiler-Explorer-Build-gcc--binutils-2.44) 15.2.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with gccrs 15.2.0 using #[unsafe(no_mangle)] fn foo() {} and compare behavior across Rust editions. Trace the edition handling for unsafe attributes, then verify that the example compiles successfully on all editions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100