Skip to content

Commit 4726e51

Browse files
authored
Rollup merge of #105791 - Ezrashaw:add-e0472-long-docs, r=GuillaumeGomez
docs: add long error explanation for error E0472 Add long-form error docs for E0472: "inline assembly not supported on this target" and update UI tests. R? `@GuillaumeGomez`
2 parents d6da428 + 082ca1e commit 4726e51

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ E0464: include_str!("./error_codes/E0464.md"),
249249
E0466: include_str!("./error_codes/E0466.md"),
250250
E0468: include_str!("./error_codes/E0468.md"),
251251
E0469: include_str!("./error_codes/E0469.md"),
252+
E0472: include_str!("./error_codes/E0472.md"),
252253
E0477: include_str!("./error_codes/E0477.md"),
253254
E0478: include_str!("./error_codes/E0478.md"),
254255
E0482: include_str!("./error_codes/E0482.md"),
@@ -599,7 +600,6 @@ E0791: include_str!("./error_codes/E0791.md"),
599600
// E0467, // removed
600601
// E0470, // removed
601602
// E0471, // constant evaluation error (in pattern)
602-
E0472, // llvm_asm! is unsupported on this target
603603
// E0473, // dereference of reference outside its lifetime
604604
// E0474, // captured variable `..` does not outlive the enclosing closure
605605
// E0475, // index of slice outside its lifetime
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Inline assembly (`asm!`) is not supported on this target.
2+
3+
Example of erroneous code:
4+
5+
```ignore (cannot-change-target)
6+
// compile-flags: --target sparc64-unknown-linux-gnu
7+
#![no_std]
8+
9+
use core::arch::asm;
10+
11+
fn main() {
12+
unsafe {
13+
asm!(""); // error: inline assembly is not supported on this target
14+
}
15+
}
16+
```
17+
18+
The Rust compiler does not support inline assembly, with the `asm!` macro
19+
(previously `llvm_asm!`), for all targets. All Tier 1 targets do support this
20+
macro but support among Tier 2 and 3 targets is not guaranteed (even when they
21+
have `std` support). Note that this error is related to
22+
`error[E0658]: inline assembly is not stable yet on this architecture`, but
23+
distinct in that with `E0472` support is not planned or in progress.
24+
25+
There is no way to easily fix this issue, however:
26+
* Consider if you really need inline assembly, is there some other way to
27+
achieve your goal (intrinsics, etc)?
28+
* Consider writing your assembly externally, linking with it and calling it
29+
from Rust.
30+
* Consider contributing to <https://github.com/rust-lang/rust> and help
31+
integrate support for your target!

src/test/ui/asm/bad-arch.mirunsafeck.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ LL | global_asm!("");
1414

1515
error: aborting due to 2 previous errors
1616

17+
For more information about this error, try `rustc --explain E0472`.

src/test/ui/asm/bad-arch.thirunsafeck.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ LL | global_asm!("");
1414

1515
error: aborting due to 2 previous errors
1616

17+
For more information about this error, try `rustc --explain E0472`.

0 commit comments

Comments
 (0)