@@ -48,7 +48,7 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
4848 }
4949 }
5050
51- let any_replacement = ssa . copy_classes ( ) . iter_enumerated ( ) . any ( | ( l , & h ) | l != h ) ;
51+ let any_replacement = !storage_to_remove . is_empty ( ) || !const_locals . is_empty ( ) ;
5252
5353 Replacer {
5454 tcx,
@@ -79,20 +79,15 @@ fn fully_moved_locals(ssa: &SsaLocals, body: &Body<'_>) -> BitSet<Local> {
7979 let mut fully_moved = BitSet :: new_filled ( body. local_decls . len ( ) ) ;
8080
8181 for ( _, rvalue, _) in ssa. assignments ( body) {
82- let ( Rvalue :: Use ( Operand :: Copy ( place) | Operand :: Move ( place) )
83- | Rvalue :: CopyForDeref ( place) ) = rvalue
84- else {
82+ let ( Rvalue :: Use ( Operand :: Copy ( place) ) | Rvalue :: CopyForDeref ( place) ) = rvalue else {
8583 continue ;
8684 } ;
8785
8886 let Some ( rhs) = place. as_local ( ) else { continue } ;
8987 if !ssa. is_ssa ( rhs) {
9088 continue ;
9189 }
92-
93- if let Rvalue :: Use ( Operand :: Copy ( _) ) | Rvalue :: CopyForDeref ( _) = rvalue {
94- fully_moved. remove ( rhs) ;
95- }
90+ fully_moved. remove ( rhs) ;
9691 }
9792
9893 ssa. meet_copy_equivalence ( & mut fully_moved) ;
@@ -173,11 +168,9 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
173168 }
174169
175170 fn visit_operand ( & mut self , operand : & mut Operand < ' tcx > , loc : Location ) {
176- if let Operand :: Move ( place) = * operand
171+ if let Operand :: Move ( place) = * operand {
177172 // A move out of a projection of a copy is equivalent to a copy of the original projection.
178- && !place. is_indirect_first_projection ( )
179- {
180- if !self . fully_moved . contains ( place. local ) {
173+ if !place. is_indirect_first_projection ( ) && !self . fully_moved . contains ( place. local ) {
181174 * operand = Operand :: Copy ( place) ;
182175 } else if let Some ( local) = place. as_local ( )
183176 && let Some ( val) = self . const_locals . get ( & local)
0 commit comments