-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I have this code
#[syscalls]
extern "C" {
pub fn exit(code: i32) -> usize;
}
which fails to compile:
error: unsafe attribute used without unsafe
--> crates/syscalls/src/lib.rs:9:1
|
9 | #[syscalls]
| ^^^^^^^^^^^ usage of unsafe attribute
|
= note: this error originates in the attribute macro `syscalls` (in Nightly builds, run with -Z macro-backtrace for more info)
help: wrap the attribute in `unsafe(...)`
|
9 | unsafe(#[syscalls])
| +++++++ +
so I try what it says:
unsafe(#[syscalls])
extern "C" {
pub fn exit(code: i32) -> usize;
}
and get another compilation error:
error: expected item, found keyword `unsafe`
--> crates/syscalls/src/lib.rs:9:1
|
9 | unsafe(#[syscalls])
| ^^^^^^ expected item
Meta
rustc --version --verbose
:
rustc 1.92.0-nightly (dd7fda570 2025-09-20)
binary: rustc
commit-hash: dd7fda570040e8a736f7d8bc28ddd1b444aabc82
commit-date: 2025-09-20
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.