@@ -48,7 +48,7 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
48
48
}
49
49
}
50
50
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 ( ) ;
52
52
53
53
Replacer {
54
54
tcx,
@@ -79,20 +79,15 @@ fn fully_moved_locals(ssa: &SsaLocals, body: &Body<'_>) -> BitSet<Local> {
79
79
let mut fully_moved = BitSet :: new_filled ( body. local_decls . len ( ) ) ;
80
80
81
81
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 {
85
83
continue ;
86
84
} ;
87
85
88
86
let Some ( rhs) = place. as_local ( ) else { continue } ;
89
87
if !ssa. is_ssa ( rhs) {
90
88
continue ;
91
89
}
92
-
93
- if let Rvalue :: Use ( Operand :: Copy ( _) ) | Rvalue :: CopyForDeref ( _) = rvalue {
94
- fully_moved. remove ( rhs) ;
95
- }
90
+ fully_moved. remove ( rhs) ;
96
91
}
97
92
98
93
ssa. meet_copy_equivalence ( & mut fully_moved) ;
@@ -173,11 +168,9 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
173
168
}
174
169
175
170
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 {
177
172
// 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 ) {
181
174
* operand = Operand :: Copy ( place) ;
182
175
} else if let Some ( local) = place. as_local ( )
183
176
&& let Some ( val) = self . const_locals . get ( & local)
0 commit comments