Skip to content

naked_asm should be safe to call #20207

Open
@usamoi

Description

@usamoi

rust-analyzer version: rust-analyzer version: 0.4.2532-standalone [/home/usamoi/.vscode/extensions/rust-lang.rust-analyzer-0.4.2532-linux-x64/server/rust-analyzer]

rustc version: rustc 1.88.0 (6b00bc388 2025-06-23)

editor or extension: VSCode

code snippet to reproduce:

#[unsafe(no_mangle)]
#[unsafe(naked)]
extern "C" fn hack() -> u64 {
    core::arch::naked_asm!("mov eax, 998244353", "ret");
}

fn main() {
    hack();
}

Rustc accepts the code without warnings, while rust-analyzer complains use of inline assembly is unsafe and requires an unsafe function or block on core::arch::naked_asm macro call.

cc rust-lang/rust#139753

Metadata

Metadata

Labels

A-diagnosticsdiagnostics / error reportingC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions