Respond to code review feedback and fix tidy
This commit is contained in:
parent
fadfd92c2f
commit
15d2b7ae81
@ -134,7 +134,9 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
|
||||
pub fn access(&self) -> InterpResult<'tcx, Operand<Tag>> {
|
||||
match self.value {
|
||||
LocalValue::Dead => throw_unsup!(DeadLocal),
|
||||
LocalValue::Uninitialized => throw_unsup!(UninitializedLocal),
|
||||
LocalValue::Uninitialized =>
|
||||
// this is reachable from ConstProp
|
||||
throw_unsup!(UninitializedLocal),
|
||||
LocalValue::Live(val) => Ok(val),
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ pub fn eval_rvalue_into_place(
|
||||
// report those as uninitialized for now.
|
||||
if let Place {
|
||||
base: PlaceBase::Local(local),
|
||||
projection: None
|
||||
projection: box []
|
||||
} = place {
|
||||
let alive =
|
||||
if let LocalValue::Live(_) = self.frame().locals[*local].value {
|
||||
|
@ -569,11 +569,15 @@ fn visit_statement(
|
||||
base: PlaceBase::Local(local),
|
||||
projection: box [],
|
||||
} = *place {
|
||||
if let Some(value) = self.const_prop(rval, place_layout, statement.source_info, place) {
|
||||
if let Some(value) = self.const_prop(rval,
|
||||
place_layout,
|
||||
statement.source_info,
|
||||
place) {
|
||||
trace!("checking whether {:?} can be stored to {:?}", value, local);
|
||||
if self.can_const_prop[local] {
|
||||
trace!("storing {:?} to {:?}", value, local);
|
||||
assert!(self.get_const(local).is_none() || self.get_const(local) == Some(value));
|
||||
assert!(self.get_const(local).is_none() ||
|
||||
self.get_const(local) == Some(value));
|
||||
self.set_const(local, value);
|
||||
|
||||
if self.should_const_prop() {
|
||||
@ -587,19 +591,22 @@ fn visit_statement(
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let StatementKind::StorageLive(local) = statement.kind {
|
||||
if self.can_const_prop[local] {
|
||||
let frame = self.ecx.frame_mut();
|
||||
|
||||
frame.locals[local].value = LocalValue::Uninitialized;
|
||||
}
|
||||
} else if let StatementKind::StorageDead(local) = statement.kind {
|
||||
if self.can_const_prop[local] {
|
||||
let frame = self.ecx.frame_mut();
|
||||
|
||||
frame.locals[local].value = LocalValue::Dead;
|
||||
} else {
|
||||
match statement.kind {
|
||||
StatementKind::StorageLive(local) |
|
||||
StatementKind::StorageDead(local) if self.can_const_prop[local] => {
|
||||
let frame = self.ecx.frame_mut();
|
||||
frame.locals[local].value =
|
||||
if let StatementKind::StorageLive(_) = statement.kind {
|
||||
LocalValue::Uninitialized
|
||||
} else {
|
||||
LocalValue::Dead
|
||||
};
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
self.super_statement(statement, location);
|
||||
}
|
||||
|
||||
|
12
src/test/ui/consts/const-prop-read-static-in-const.rs
Normal file
12
src/test/ui/consts/const-prop-read-static-in-const.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
// run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
const TEST: u8 = MY_STATIC;
|
||||
//~^ skipping const checks
|
||||
|
||||
static MY_STATIC: u8 = 4;
|
||||
|
||||
fn main() {
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
warning: skipping const checks
|
||||
--> $DIR/const-prop-read-static-in-const.rs:6:18
|
||||
|
|
||||
LL | const TEST: u8 = MY_STATIC;
|
||||
| ^^^^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user