Reduce rightward drift.

This commit is contained in:
Camille GILLOT 2023-04-15 16:27:55 +00:00
parent dd452ae70e
commit dd78b997b5

View file

@ -110,11 +110,10 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
// we must make sure that all `target as Variant#i` are `Top`.
state.flood(target.as_ref(), self.map());
if let Some(target_idx) = self.map().find(target.as_ref()) {
let Some(target_idx) = self.map().find(target.as_ref()) else { return };
let (variant_target, variant_index) = match **kind {
AggregateKind::Tuple | AggregateKind::Closure(..) => {
(Some(target_idx), None)
}
AggregateKind::Tuple | AggregateKind::Closure(..) => (Some(target_idx), None),
AggregateKind::Adt(def_id, variant_index, ..) => {
match self.tcx.def_kind(def_id) {
DefKind::Struct => (Some(target_idx), None),
@ -122,10 +121,10 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
self.map.apply(target_idx, TrackElem::Variant(variant_index)),
Some(variant_index),
),
_ => (None, None),
_ => return,
}
}
_ => (None, None),
_ => return,
};
if let Some(variant_target_idx) = variant_target {
for (field_index, operand) in operands.iter().enumerate() {
@ -152,7 +151,6 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
}
}
}
}
Rvalue::CheckedBinaryOp(op, box (left, right)) => {
// Flood everything now, so we can use `insert_value_idx` directly later.
state.flood(target.as_ref(), self.map());