about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-10-03 21:06:49 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-10-03 21:06:49 +0200
commit20489eaca2ad541a35059d38e2b064c46d3bcc9f (patch)
treee403c90b1a42c6ee4b72e3f67d7f6dba410bcb7f /compiler
parent529c35331bb3817e90b5099c33d97aa55ad2713d (diff)
downloadrust-20489eaca2ad541a35059d38e2b064c46d3bcc9f.tar.gz
rust-20489eaca2ad541a35059d38e2b064c46d3bcc9f.zip
Update comments
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_transform/src/simplify_try.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/compiler/rustc_mir_transform/src/simplify_try.rs b/compiler/rustc_mir_transform/src/simplify_try.rs
index 8da90a432ce..f8c616a19e9 100644
--- a/compiler/rustc_mir_transform/src/simplify_try.rs
+++ b/compiler/rustc_mir_transform/src/simplify_try.rs
@@ -713,6 +713,8 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
                 ty::Adt(adt, _) if adt.is_enum() => adt,
                 _ => return StatementEquality::NotEqual,
             };
+            // We need to make sure that the switch value that targets the bb with
+            // SetDiscriminant is the same as the variant discriminant.
             let variant_discr = adt.discriminant_for_variant(self.tcx, *variant_index).val;
             if variant_discr != switch_value {
                 trace!(
@@ -750,20 +752,28 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
             (
                 StatementKind::Assign(box (_, rhs)),
                 StatementKind::SetDiscriminant { place, variant_index },
-            )
-            // we need to make sure that the switch value that targets the bb with SetDiscriminant (y), is the same as the variant index
-            if y_target_and_value.value.is_some() => {
+            ) if y_target_and_value.value.is_some() => {
                 // choose basic block of x, as that has the assign
-                helper(rhs, place, variant_index, y_target_and_value.value.unwrap(), x_target_and_value.target)
+                helper(
+                    rhs,
+                    place,
+                    variant_index,
+                    y_target_and_value.value.unwrap(),
+                    x_target_and_value.target,
+                )
             }
             (
                 StatementKind::SetDiscriminant { place, variant_index },
                 StatementKind::Assign(box (_, rhs)),
-            )
-            // we need to make sure that the switch value that targets the bb with SetDiscriminant (x), is the same as the variant index
-            if x_target_and_value.value.is_some() => {
+            ) if x_target_and_value.value.is_some() => {
                 // choose basic block of y, as that has the assign
-                helper(rhs, place, variant_index, x_target_and_value.value.unwrap(), y_target_and_value.target)
+                helper(
+                    rhs,
+                    place,
+                    variant_index,
+                    x_target_and_value.value.unwrap(),
+                    y_target_and_value.target,
+                )
             }
             _ => {
                 trace!("NO: statements `{:?}` and `{:?}` not considered equal", x, y);