also const-check FakeRead
This commit is contained in:
parent
bd2f1cb278
commit
f4085f0d3a
4 changed files with 40 additions and 7 deletions
|
@ -722,17 +722,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
||||||
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
||||||
trace!("visit_statement: statement={:?} location={:?}", statement, location);
|
trace!("visit_statement: statement={:?} location={:?}", statement, location);
|
||||||
|
|
||||||
match statement.kind {
|
|
||||||
StatementKind::Assign(..) | StatementKind::SetDiscriminant { .. } => {
|
|
||||||
self.super_statement(statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
|
||||||
|
|
||||||
|
match statement.kind {
|
||||||
StatementKind::LlvmInlineAsm { .. } => {
|
StatementKind::LlvmInlineAsm { .. } => {
|
||||||
self.super_statement(statement, location);
|
|
||||||
self.check_op(ops::InlineAsm);
|
self.check_op(ops::InlineAsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatementKind::FakeRead(..)
|
StatementKind::Assign(..)
|
||||||
|
| StatementKind::SetDiscriminant { .. }
|
||||||
|
| StatementKind::FakeRead(..)
|
||||||
| StatementKind::StorageLive(_)
|
| StatementKind::StorageLive(_)
|
||||||
| StatementKind::StorageDead(_)
|
| StatementKind::StorageDead(_)
|
||||||
| StatementKind::Retag { .. }
|
| StatementKind::Retag { .. }
|
||||||
|
|
|
@ -146,6 +146,11 @@ help: skipping check that does not even have a feature gate
|
||||||
|
|
|
|
||||||
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
help: skipping check that does not even have a feature gate
|
||||||
|
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
||||||
|
|
|
||||||
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
help: skipping check for `const_panic` feature
|
help: skipping check for `const_panic` feature
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
|
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
|
||||||
|
|
|
|
||||||
|
|
|
@ -5,5 +5,16 @@ const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
|
||||||
const VALUE: u8 = unsafe { *REG_ADDR };
|
const VALUE: u8 = unsafe { *REG_ADDR };
|
||||||
//~^ ERROR dereferencing raw pointers in constants is unstable
|
//~^ ERROR dereferencing raw pointers in constants is unstable
|
||||||
|
|
||||||
|
const unsafe fn unreachable() -> ! {
|
||||||
|
use std::convert::Infallible;
|
||||||
|
|
||||||
|
const INFALLIBLE: *const Infallible = [].as_ptr();
|
||||||
|
match *INFALLIBLE {}
|
||||||
|
//~^ ERROR dereferencing raw pointers in constant functions is unstable
|
||||||
|
|
||||||
|
const BAD: () = unsafe { match *INFALLIBLE {} };
|
||||||
|
//~^ ERROR dereferencing raw pointers in constants is unstable
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,24 @@ LL | const VALUE: u8 = unsafe { *REG_ADDR };
|
||||||
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
|
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
|
||||||
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
|
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0658]: dereferencing raw pointers in constant functions is unstable
|
||||||
|
--> $DIR/E0396.rs:12:11
|
||||||
|
|
|
||||||
|
LL | match *INFALLIBLE {}
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
|
||||||
|
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: dereferencing raw pointers in constants is unstable
|
||||||
|
--> $DIR/E0396.rs:15:36
|
||||||
|
|
|
||||||
|
LL | const BAD: () = unsafe { match *INFALLIBLE {} };
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
|
||||||
|
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue