@@ -27,37 +27,34 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
2727 #[ instrument( level = "trace" , skip( self , tcx, body) ) ]
2828 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
2929 debug ! ( def_id = ?body. source. def_id( ) ) ;
30- propagate_ssa ( tcx, body) ;
31- }
32- }
3330
34- fn propagate_ssa < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
35- let param_env = tcx. param_env_reveal_all_normalized ( body. source . def_id ( ) ) ;
36- let ssa = SsaLocals :: new ( tcx, body, param_env) ;
31+ let param_env = tcx. param_env_reveal_all_normalized ( body. source . def_id ( ) ) ;
32+ let ssa = SsaLocals :: new ( tcx, body, param_env) ;
3733
38- let fully_moved = fully_moved_locals ( & ssa, body) ;
39- debug ! ( ?fully_moved) ;
34+ let fully_moved = fully_moved_locals ( & ssa, body) ;
35+ debug ! ( ?fully_moved) ;
4036
41- let mut storage_to_remove = BitSet :: new_empty ( fully_moved. domain_size ( ) ) ;
42- for ( local, & head) in ssa. copy_classes ( ) . iter_enumerated ( ) {
43- if local != head {
44- storage_to_remove. insert ( head) ;
37+ let mut storage_to_remove = BitSet :: new_empty ( fully_moved. domain_size ( ) ) ;
38+ for ( local, & head) in ssa. copy_classes ( ) . iter_enumerated ( ) {
39+ if local != head {
40+ storage_to_remove. insert ( head) ;
41+ }
4542 }
46- }
4743
48- let any_replacement = ssa. copy_classes ( ) . iter_enumerated ( ) . any ( |( l, & h) | l != h) ;
44+ let any_replacement = ssa. copy_classes ( ) . iter_enumerated ( ) . any ( |( l, & h) | l != h) ;
4945
50- Replacer {
51- tcx,
52- copy_classes : ssa. copy_classes ( ) ,
53- fully_moved,
54- borrowed_locals : ssa. borrowed_locals ( ) ,
55- storage_to_remove,
56- }
57- . visit_body_preserves_cfg ( body) ;
46+ Replacer {
47+ tcx,
48+ copy_classes : ssa. copy_classes ( ) ,
49+ fully_moved,
50+ borrowed_locals : ssa. borrowed_locals ( ) ,
51+ storage_to_remove,
52+ }
53+ . visit_body_preserves_cfg ( body) ;
5854
59- if any_replacement {
60- crate :: simplify:: remove_unused_definitions ( body) ;
55+ if any_replacement {
56+ crate :: simplify:: remove_unused_definitions ( body) ;
57+ }
6158 }
6259}
6360
@@ -140,7 +137,8 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
140137
141138 fn visit_operand ( & mut self , operand : & mut Operand < ' tcx > , loc : Location ) {
142139 if let Operand :: Move ( place) = * operand
143- // A move out of a projection of a copy is equivalent to a copy of the original projection.
140+ // A move out of a projection of a copy is equivalent to a copy of the original
141+ // projection.
144142 && !place. is_indirect_first_projection ( )
145143 && !self . fully_moved . contains ( place. local )
146144 {
0 commit comments