]> git.lizzy.rs Git - rust.git/commitdiff
MatchBranchSimplification: optimize when switching on copy operand
authorTomasz Miąsko <tomasz.miasko@gmail.com>
Fri, 14 Aug 2020 00:00:00 +0000 (00:00 +0000)
committerTomasz Miąsko <tomasz.miasko@gmail.com>
Fri, 14 Aug 2020 19:58:10 +0000 (21:58 +0200)
src/librustc_mir/transform/match_branches.rs

index 67021ae512b654a699bbc63a288fc99250013056..e6c5845cd481abce415d29a548af45b192c4dbe0 100644 (file)
@@ -16,7 +16,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx
         'outer: for bb_idx in bbs.indices() {
             let (discr, val, switch_ty, first, second) = match bbs[bb_idx].terminator().kind {
                 TerminatorKind::SwitchInt {
-                    discr: Operand::Move(ref place),
+                    discr: Operand::Copy(ref place) | Operand::Move(ref place),
                     switch_ty,
                     ref targets,
                     ref values,