Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference for asm-goto #1693

Merged
merged 7 commits into from
Mar 18, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make some editorial adjustments
  • Loading branch information
traviscross authored and nbdd0121 committed Feb 10, 2025
commit 83f880647bbf14b4d1d034b90d0873c7828dcd3f
10 changes: 5 additions & 5 deletions src/inline-assembly.md
Original file line number Diff line number Diff line change
@@ -356,10 +356,10 @@ assert_eq!(y, [3, 2, 0, 1]);

r[asm.operand-type.supported-operands.label]
* `label <block>`
- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted addresses.
- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted address.
- After execution of the block, the `asm!` expression returns.
- The type of the block must be unit or `!` (never).
- The block starts new safety context; despite the outer `unsafe` needed for `asm!`, you need an extra `unsafe` to perform unsafe operations inside the block.
- The block starts a new safety context; despite the outer `unsafe` block needed for `asm!`, unsafe operations within the `label` block must be wrapped in an inner `unsafe` block.

```rust
# #[cfg(target_arch = "x86_64")]
@@ -1097,8 +1097,8 @@ r[asm.options.supported-options.noreturn]
- `noreturn`: The `asm!` block never returns, and its return type is defined as `!` (never).
Behavior is undefined if execution falls through past the end of the asm code.
A `noreturn` asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.
- When labels are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.
The entire `asm!` block will have unit type in this case, unless all label blocks diverge, in which case the return type is `!`.
- When any `label` blocks are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.
The entire `asm!` block will have unit type in this case, unless all `label` blocks diverge, in which case the return type is `!`.

<!-- no_run: This test aborts at runtime -->
```rust,no_run
@@ -1186,7 +1186,7 @@ r[asm.options.checks.noreturn]
- It is a compile-time error to specify `noreturn` on an asm block with outputs and without labels.

r[asm.options.checks.label-with-outputs]
- It is a compile-time error to specify label on an asm block with outputs.
- It is a compile-time error to have any `label` blocks in an asm block with outputs.

```rust,compile_fail
# #[cfg(target_arch = "x86_64")] {