Recurse into statement before applying its effect.
This commit is contained in:
parent
d97a7ce69b
commit
f00be8b77b
3 changed files with 14 additions and 10 deletions
|
@ -829,6 +829,10 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
|
|
||||||
fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) {
|
fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) {
|
||||||
trace!("visit_statement: {:?}", statement);
|
trace!("visit_statement: {:?}", statement);
|
||||||
|
|
||||||
|
// Recurse into statement before applying the assignment.
|
||||||
|
self.super_statement(statement, location);
|
||||||
|
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
StatementKind::Assign(box (place, ref mut rval)) => {
|
StatementKind::Assign(box (place, ref mut rval)) => {
|
||||||
let can_const_prop = self.ecx.machine.can_const_prop[place.local];
|
let can_const_prop = self.ecx.machine.can_const_prop[place.local];
|
||||||
|
@ -905,8 +909,6 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_statement(statement, location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
|
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
|
||||||
|
|
|
@ -511,6 +511,10 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
trace!("visit_statement: {:?}", statement);
|
trace!("visit_statement: {:?}", statement);
|
||||||
let source_info = statement.source_info;
|
let source_info = statement.source_info;
|
||||||
self.source_info = Some(source_info);
|
self.source_info = Some(source_info);
|
||||||
|
|
||||||
|
// Recurse into statement before applying the assignment.
|
||||||
|
self.super_statement(statement, location);
|
||||||
|
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
StatementKind::Assign(box (place, ref rval)) => {
|
StatementKind::Assign(box (place, ref rval)) => {
|
||||||
let can_const_prop = self.ecx.machine.can_const_prop[place.local];
|
let can_const_prop = self.ecx.machine.can_const_prop[place.local];
|
||||||
|
@ -576,8 +580,6 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_statement(statement, location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
|
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
|
||||||
|
|
|
@ -10,12 +10,6 @@ note: erroneous constant used
|
||||||
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
note: erroneous constant used
|
|
||||||
--> $DIR/const-err-late.rs:19:16
|
|
||||||
|
|
|
||||||
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0080]: evaluation of `S::<u32>::FOO` failed
|
error[E0080]: evaluation of `S::<u32>::FOO` failed
|
||||||
--> $DIR/const-err-late.rs:13:21
|
--> $DIR/const-err-late.rs:13:21
|
||||||
|
|
|
|
||||||
|
@ -34,6 +28,12 @@ note: erroneous constant used
|
||||||
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-err-late.rs:19:16
|
||||||
|
|
|
||||||
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue