Check for llvm_asm
in a const context
This commit is contained in:
parent
dbf8b6bf11
commit
65a985e81e
4 changed files with 23 additions and 1 deletions
|
@ -147,6 +147,10 @@ impl NonConstOp for IfOrMatch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct InlineAsm;
|
||||||
|
impl NonConstOp for InlineAsm {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LiveDrop;
|
pub struct LiveDrop;
|
||||||
impl NonConstOp for LiveDrop {
|
impl NonConstOp for LiveDrop {
|
||||||
|
|
|
@ -481,11 +481,14 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
||||||
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
|
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
|
||||||
self.check_op(ops::IfOrMatch);
|
self.check_op(ops::IfOrMatch);
|
||||||
}
|
}
|
||||||
|
StatementKind::LlvmInlineAsm { .. } => {
|
||||||
|
self.check_op(ops::InlineAsm);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) should these really do nothing?
|
// FIXME(eddyb) should these really do nothing?
|
||||||
StatementKind::FakeRead(..)
|
StatementKind::FakeRead(..)
|
||||||
| StatementKind::StorageLive(_)
|
| StatementKind::StorageLive(_)
|
||||||
| StatementKind::StorageDead(_)
|
| StatementKind::StorageDead(_)
|
||||||
| StatementKind::LlvmInlineAsm { .. }
|
|
||||||
| StatementKind::Retag { .. }
|
| StatementKind::Retag { .. }
|
||||||
| StatementKind::AscribeUserType(..)
|
| StatementKind::AscribeUserType(..)
|
||||||
| StatementKind::Nop => {}
|
| StatementKind::Nop => {}
|
||||||
|
|
6
src/test/ui/consts/inline_asm.rs
Normal file
6
src/test/ui/consts/inline_asm.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#![feature(llvm_asm)]
|
||||||
|
|
||||||
|
const _: () = unsafe { llvm_asm!("nop") };
|
||||||
|
//~^ ERROR contains unimplemented expression type
|
||||||
|
|
||||||
|
fn main() {}
|
9
src/test/ui/consts/inline_asm.stderr
Normal file
9
src/test/ui/consts/inline_asm.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0019]: constant contains unimplemented expression type
|
||||||
|
--> $DIR/inline_asm.rs:3:1
|
||||||
|
|
|
||||||
|
LL | const _: () = unsafe { llvm_asm!("nop") };
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0019`.
|
Loading…
Add table
Add a link
Reference in a new issue