Rollup merge of #75227 - Amanieu:fix_asm_arch, r=Mark-Simulacrum

Fix ICE when using asm! on an unsupported architecture

Fixes #75220
This commit is contained in:
Manish Goregaokar 2020-08-06 23:04:07 -07:00 committed by GitHub
commit 9ab750d05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {