Assign correct span to new illegal ops

This commit is contained in:
Dylan MacKenzie 2020-04-21 09:24:41 -07:00
parent 79543397d7
commit 152c06569b
4 changed files with 14 additions and 11 deletions

View File

@ -485,9 +485,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
| FakeReadCause::ForGuardBinding,
_,
) => {
self.super_statement(statement, location);
self.check_op(ops::IfOrMatch);
}
StatementKind::LlvmInlineAsm { .. } => {
self.super_statement(statement, location);
self.check_op(ops::InlineAsm);
}

View File

@ -1,8 +1,10 @@
error[E0019]: constant contains unimplemented expression type
--> $DIR/inline_asm.rs:3:1
--> $DIR/inline_asm.rs:3:24
|
LL | const _: () = unsafe { llvm_asm!("nop") };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View File

@ -6,9 +6,11 @@
fn main() {}
// Make sure we catch executing inline assembly.
static TEST_BAD: () = { //~ WARN: skipping const checks
static TEST_BAD: () = {
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
//~^ ERROR could not evaluate static initializer
//~| NOTE in this expansion of llvm_asm!
//~| NOTE inline assembly is not supported
//~| WARN skipping const checks
//~| NOTE in this expansion of llvm_asm!
};

View File

@ -1,13 +1,10 @@
warning: skipping const checks
--> $DIR/inline_asm.rs:9:1
--> $DIR/inline_asm.rs:10:14
|
LL | / static TEST_BAD: () = {
LL | | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
LL | |
LL | |
LL | |
LL | | };
| |__^
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: could not evaluate static initializer
--> $DIR/inline_asm.rs:10:14