Recurse into statement before applying its effect.

This commit is contained in:
Camille GILLOT 2023-03-07 15:40:38 +00:00
parent d97a7ce69b
commit f00be8b77b
3 changed files with 14 additions and 10 deletions

View File

@ -829,6 +829,10 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
fn visit_statement(&mut self, statement: &mut Statement<'tcx>, location: Location) {
trace!("visit_statement: {:?}", statement);
// Recurse into statement before applying the assignment.
self.super_statement(statement, location);
match statement.kind {
StatementKind::Assign(box (place, ref mut rval)) => {
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) {

View File

@ -511,6 +511,10 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
trace!("visit_statement: {:?}", statement);
let source_info = statement.source_info;
self.source_info = Some(source_info);
// Recurse into statement before applying the assignment.
self.super_statement(statement, location);
match statement.kind {
StatementKind::Assign(box (place, ref rval)) => {
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) {

View File

@ -10,12 +10,6 @@ note: erroneous constant used
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
--> $DIR/const-err-late.rs:13:21
|
@ -34,6 +28,12 @@ note: erroneous constant used
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
For more information about this error, try `rustc --explain E0080`.