]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_transform/src/simplify_branches.rs
Rollup merge of #90247 - newpavlov:duration_float_fract, r=nagisa
[rust.git] / compiler / rustc_mir_transform / src / simplify_branches.rs
index 4b261334f3e545d7d4718de15b106861abed1c24..3bbae5b8976ccde862a084291b64948a56de8315 100644 (file)
@@ -33,15 +33,8 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
                 } => {
                     let constant = c.literal.try_eval_bits(tcx, param_env, switch_ty);
                     if let Some(constant) = constant {
-                        let otherwise = targets.otherwise();
-                        let mut ret = TerminatorKind::Goto { target: otherwise };
-                        for (v, t) in targets.iter() {
-                            if v == constant {
-                                ret = TerminatorKind::Goto { target: t };
-                                break;
-                            }
-                        }
-                        ret
+                        let target = targets.target_for_value(constant);
+                        TerminatorKind::Goto { target }
                     } else {
                         continue;
                     }