Skip to content

Commit 9abdb6d

Browse files
committed
Fix ICE when using asm! on an unsupported architecture
Fixes #75220
1 parent c15bae5 commit 9abdb6d

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

src/librustc_ast_lowering/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10671067
.collect();
10681068

10691069
// Stop if there were any errors when lowering the register classes
1070-
if operands.len() != asm.operands.len() {
1070+
if operands.len() != asm.operands.len() || sess.asm_arch.is_none() {
10711071
return hir::ExprKind::Err;
10721072
}
10731073

src/test/ui/asm/bad-arch.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// compile-flags: --target wasm32-unknown-unknown
2+
3+
#![feature(no_core, lang_items, rustc_attrs)]
4+
#![no_core]
5+
6+
#[rustc_builtin_macro]
7+
macro_rules! asm {
8+
() => {};
9+
}
10+
#[lang = "sized"]
11+
trait Sized {}
12+
13+
fn main() {
14+
unsafe {
15+
asm!("");
16+
//~^ ERROR asm! is unsupported on this target
17+
}
18+
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error[E0472]: asm! is unsupported on this target
2+
--> $DIR/bad-arch.rs:15:9
3+
|
4+
LL | asm!("");
5+
| ^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/feature-gates/feature-gate-asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ignore-emscripten
1+
// only-x86_64
22

33
fn main() {
44
unsafe {

src/test/ui/feature-gates/feature-gate-asm2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ignore-emscripten
1+
// only-x86_64
22

33
fn main() {
44
unsafe {

0 commit comments

Comments
 (0)