Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/inline-assembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,9 @@ extern "sysv64-unwind" fn may_panic() {
r[asm.validity]
### Correctness and validity

r[asm.validity.unsafe]
Using `asm!` requires `unsafe`, and the programmer is responsible for ensuring that the assembly code is correct and valid.

r[asm.validity.necessary-but-not-sufficient]
In addition to all of the previous rules, the string argument to `asm!` must ultimately become---after all other arguments are evaluated, formatting is performed, and operands are translated---assembly that is both syntactically correct and semantically valid for the target architecture. The formatting rules allow the compiler to generate assembly with correct syntax. Rules concerning operands permit valid translation of Rust operands into and out of the assembly code. Adherence to these rules is necessary, but not sufficient, for the final expanded assembly to be both correct and valid. For instance:

Expand Down
4 changes: 4 additions & 0 deletions src/unsafety.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ r[safety.unsafe-extern]
r[safety.unsafe-attribute]
- Applying an [unsafe attribute] to an item.

r[safety.unsafe-asm]
- Using the [`asm!`] macro.

[^extern-2024]: Prior to the 2024 edition, extern blocks were allowed to be declared without `unsafe`.

[`extern`]: items/external-blocks.md
Expand All @@ -40,3 +43,4 @@ r[safety.unsafe-attribute]
[raw pointer]: types/pointer.md
[unsafe trait]: items/traits.md#unsafe-traits
[unsafe attribute]: attributes.md
[`asm!`]: inline-assembly.md
Loading