Skip to content

Commit 20489ea

Browse files
committed
Update comments
1 parent 529c353 commit 20489ea

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

compiler/rustc_mir_transform/src/simplify_try.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
713713
ty::Adt(adt, _) if adt.is_enum() => adt,
714714
_ => return StatementEquality::NotEqual,
715715
};
716+
// We need to make sure that the switch value that targets the bb with
717+
// SetDiscriminant is the same as the variant discriminant.
716718
let variant_discr = adt.discriminant_for_variant(self.tcx, *variant_index).val;
717719
if variant_discr != switch_value {
718720
trace!(
@@ -750,20 +752,28 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
750752
(
751753
StatementKind::Assign(box (_, rhs)),
752754
StatementKind::SetDiscriminant { place, variant_index },
753-
)
754-
// we need to make sure that the switch value that targets the bb with SetDiscriminant (y), is the same as the variant index
755-
if y_target_and_value.value.is_some() => {
755+
) if y_target_and_value.value.is_some() => {
756756
// choose basic block of x, as that has the assign
757-
helper(rhs, place, variant_index, y_target_and_value.value.unwrap(), x_target_and_value.target)
757+
helper(
758+
rhs,
759+
place,
760+
variant_index,
761+
y_target_and_value.value.unwrap(),
762+
x_target_and_value.target,
763+
)
758764
}
759765
(
760766
StatementKind::SetDiscriminant { place, variant_index },
761767
StatementKind::Assign(box (_, rhs)),
762-
)
763-
// we need to make sure that the switch value that targets the bb with SetDiscriminant (x), is the same as the variant index
764-
if x_target_and_value.value.is_some() => {
768+
) if x_target_and_value.value.is_some() => {
765769
// choose basic block of y, as that has the assign
766-
helper(rhs, place, variant_index, x_target_and_value.value.unwrap(), y_target_and_value.target)
770+
helper(
771+
rhs,
772+
place,
773+
variant_index,
774+
x_target_and_value.value.unwrap(),
775+
y_target_and_value.target,
776+
)
767777
}
768778
_ => {
769779
trace!("NO: statements `{:?}` and `{:?}` not considered equal", x, y);

0 commit comments

Comments
 (0)