Merge if-let and match.
This commit is contained in:
parent
4a75995fbd
commit
d0934f14c7
1 changed files with 64 additions and 68 deletions
|
@ -917,7 +917,8 @@ impl<'tcx> MutVisitor<'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);
|
||||||
if let StatementKind::Assign(box (place, ref mut rval)) = statement.kind {
|
match statement.kind {
|
||||||
|
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];
|
||||||
if let Some(()) = self.const_prop(rval, place) {
|
if let Some(()) = self.const_prop(rval, place) {
|
||||||
// This will return None if the above `const_prop` invocation only "wrote" a
|
// This will return None if the above `const_prop` invocation only "wrote" a
|
||||||
|
@ -966,8 +967,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
);
|
);
|
||||||
Self::remove_const(&mut self.ecx, place.local);
|
Self::remove_const(&mut self.ecx, place.local);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
match statement.kind {
|
|
||||||
StatementKind::SetDiscriminant { ref place, .. } => {
|
StatementKind::SetDiscriminant { ref place, .. } => {
|
||||||
match self.ecx.machine.can_const_prop[place.local] {
|
match self.ecx.machine.can_const_prop[place.local] {
|
||||||
ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {
|
ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {
|
||||||
|
@ -984,18 +984,14 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
|
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
|
||||||
let frame = self.ecx.frame_mut();
|
let frame = self.ecx.frame_mut();
|
||||||
frame.locals[local].value =
|
frame.locals[local].value = if let StatementKind::StorageLive(_) = statement.kind {
|
||||||
if let StatementKind::StorageLive(_) = statement.kind {
|
LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit))
|
||||||
LocalValue::Live(interpret::Operand::Immediate(
|
|
||||||
interpret::Immediate::Uninit,
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
LocalValue::Dead
|
LocalValue::Dead
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.super_statement(statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue