Fix ICE when using asm! on an unsupported architecture

Fixes #75220
This commit is contained in:
Amanieu d'Antras 2020-08-06 19:52:15 +01:00
parent c15bae53b5
commit 9abdb6db6f
5 changed files with 29 additions and 3 deletions

View File

@ -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;
}

View File

@ -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
}
}

View File

@ -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

View File

@ -1,4 +1,4 @@
// ignore-emscripten
// only-x86_64
fn main() {
unsafe {

View File

@ -1,4 +1,4 @@
// ignore-emscripten
// only-x86_64
fn main() {
unsafe {