Skip to content

Commit 082ca1e

Browse files
committed
docs: add long error explanation for error E0472
1 parent c43bc13 commit 082ca1e

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
@@ -248,6 +248,7 @@ E0464: include_str!("./error_codes/E0464.md"),
248248
E0466: include_str!("./error_codes/E0466.md"),
249249
E0468: include_str!("./error_codes/E0468.md"),
250250
E0469: include_str!("./error_codes/E0469.md"),
251+
E0472: include_str!("./error_codes/E0472.md"),
251252
E0477: include_str!("./error_codes/E0477.md"),
252253
E0478: include_str!("./error_codes/E0478.md"),
253254
E0482: include_str!("./error_codes/E0482.md"),
@@ -600,7 +601,6 @@ E0791: include_str!("./error_codes/E0791.md"),
600601
// E0467, // removed
601602
// E0470, // removed
602603
// E0471, // constant evaluation error (in pattern)
603-
E0472, // llvm_asm! is unsupported on this target
604604
// E0473, // dereference of reference outside its lifetime
605605
// E0474, // captured variable `..` does not outlive the enclosing closure
606606
// 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)