mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Check for llvm_asm
in a const context
This commit is contained in:
parent
dbf8b6bf11
commit
65a985e81e
@ -147,6 +147,10 @@ impl NonConstOp for IfOrMatch {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InlineAsm;
|
||||
impl NonConstOp for InlineAsm {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LiveDrop;
|
||||
impl NonConstOp for LiveDrop {
|
||||
|
@ -481,11 +481,14 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
||||
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
|
||||
self.check_op(ops::IfOrMatch);
|
||||
}
|
||||
StatementKind::LlvmInlineAsm { .. } => {
|
||||
self.check_op(ops::InlineAsm);
|
||||
}
|
||||
|
||||
// FIXME(eddyb) should these really do nothing?
|
||||
StatementKind::FakeRead(..)
|
||||
| StatementKind::StorageLive(_)
|
||||
| StatementKind::StorageDead(_)
|
||||
| StatementKind::LlvmInlineAsm { .. }
|
||||
| StatementKind::Retag { .. }
|
||||
| StatementKind::AscribeUserType(..)
|
||||
| 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…
Reference in New Issue
Block a user