Skip to content

Commit

Permalink
Rollup merge of rust-lang#75227 - Amanieu:fix_asm_arch, r=Mark-Simula…
Browse files Browse the repository at this point in the history
…crum

Fix ICE when using asm! on an unsupported architecture

Fixes rust-lang#75220
  • Loading branch information
Manishearth committed Aug 7, 2020
2 parents 25c8e9a + 9abdb6d commit 9ab750d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.collect();

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

Expand Down
18 changes: 18 additions & 0 deletions src/test/ui/asm/bad-arch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// compile-flags: --target wasm32-unknown-unknown

#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]

#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}
#[lang = "sized"]
trait Sized {}

fn main() {
unsafe {
asm!("");
//~^ ERROR asm! is unsupported on this target
}
}
8 changes: 8 additions & 0 deletions src/test/ui/asm/bad-arch.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error[E0472]: asm! is unsupported on this target
--> $DIR/bad-arch.rs:15:9
|
LL | asm!("");
| ^^^^^^^^^

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore-emscripten
// only-x86_64

fn main() {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore-emscripten
// only-x86_64

fn main() {
unsafe {
Expand Down

0 comments on commit 9ab750d

Please sign in to comment.