Skip to content

Commit 3233565

Browse files
committed
Mark asm unstable book doctests as allow_fail since they don't work with system LLVM
1 parent cecffdc commit 3233565

File tree

1 file changed

+14
-14
lines changed
  • src/doc/unstable-book/src/library-features

1 file changed

+14
-14
lines changed

src/doc/unstable-book/src/library-features/asm.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cannot be otherwise achieved. Accessing low level hardware primitives, e.g. in k
2424

2525
Let us start with the simplest possible example:
2626

27-
```rust
27+
```rust,allow_fail
2828
# #![feature(asm)]
2929
unsafe {
3030
asm!("nop");
@@ -41,7 +41,7 @@ in the first argument of the `asm!` macro as a string literal.
4141
Now inserting an instruction that does nothing is rather boring. Let us do something that
4242
actually acts on data:
4343

44-
```rust
44+
```rust,allow_fail
4545
# #![feature(asm)]
4646
let x: u64;
4747
unsafe {
@@ -63,7 +63,7 @@ the template and will read the variable from there after the inline assembly fin
6363

6464
Let us see another example that also uses an input:
6565

66-
```rust
66+
```rust,allow_fail
6767
# #![feature(asm)]
6868
let i: u64 = 3;
6969
let o: u64;
@@ -95,7 +95,7 @@ readability, and allows reordering instructions without changing the argument or
9595

9696
We can further refine the above example to avoid the `mov` instruction:
9797

98-
```rust
98+
```rust,allow_fail
9999
# #![feature(asm)]
100100
let mut x: u64 = 3;
101101
unsafe {
@@ -109,7 +109,7 @@ This is different from specifying an input and output separately in that it is g
109109

110110
It is also possible to specify different variables for the input and output parts of an `inout` operand:
111111

112-
```rust
112+
```rust,allow_fail
113113
# #![feature(asm)]
114114
let x: u64 = 3;
115115
let y: u64;
@@ -131,7 +131,7 @@ There is also a `inlateout` variant of this specifier.
131131

132132
Here is an example where `inlateout` *cannot* be used:
133133

134-
```rust
134+
```rust,allow_fail
135135
# #![feature(asm)]
136136
let mut a: u64 = 4;
137137
let b: u64 = 4;
@@ -149,7 +149,7 @@ Here the compiler is free to allocate the same register for inputs `b` and `c` s
149149

150150
However the following example can use `inlateout` since the output is only modified after all input registers have been read:
151151

152-
```rust
152+
```rust,allow_fail
153153
# #![feature(asm)]
154154
let mut a: u64 = 4;
155155
let b: u64 = 4;
@@ -168,7 +168,7 @@ Therefore, Rust inline assembly provides some more specific constraint specifier
168168
While `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`
169169
among others can be addressed by their name.
170170

171-
```rust,no_run
171+
```rust,allow_fail,no_run
172172
# #![feature(asm)]
173173
let cmd = 0xd1;
174174
unsafe {
@@ -184,7 +184,7 @@ Note that unlike other operand types, explicit register operands cannot be used
184184

185185
Consider this example which uses the x86 `mul` instruction:
186186

187-
```rust
187+
```rust,allow_fail
188188
# #![feature(asm)]
189189
fn mul(a: u64, b: u64) -> u128 {
190190
let lo: u64;
@@ -220,7 +220,7 @@ This state is generally referred to as being "clobbered".
220220
We need to tell the compiler about this since it may need to save and restore this state
221221
around the inline assembly block.
222222

223-
```rust
223+
```rust,allow_fail
224224
# #![feature(asm)]
225225
let ebx: u32;
226226
let ecx: u32;
@@ -250,7 +250,7 @@ However we still need to tell the compiler that `eax` and `edx` have been modifi
250250

251251
This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:
252252

253-
```rust
253+
```rust,allow_fail
254254
# #![feature(asm)]
255255
// Multiply x by 6 using shifts and adds
256256
let mut x: u64 = 4;
@@ -270,7 +270,7 @@ assert_eq!(x, 4 * 6);
270270
A special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.
271271
This allows you to call a function or access a global variable without needing to keep its address in a register.
272272

273-
```rust
273+
```rust,allow_fail
274274
# #![feature(asm)]
275275
extern "C" fn foo(arg: i32) {
276276
println!("arg = {}", arg);
@@ -306,7 +306,7 @@ By default the compiler will always choose the name that refers to the full regi
306306

307307
This default can be overriden by using modifiers on the template string operands, just like you would with format strings:
308308

309-
```rust
309+
```rust,allow_fail
310310
# #![feature(asm)]
311311
let mut x: u16 = 0xab;
312312
@@ -330,7 +330,7 @@ By default, an inline assembly block is treated the same way as an external FFI
330330

331331
Let's take our previous example of an `add` instruction:
332332

333-
```rust
333+
```rust,allow_fail
334334
# #![feature(asm)]
335335
let mut a: u64 = 4;
336336
let b: u64 = 4;

0 commit comments

Comments
 (0)