@@ -85,15 +85,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
85
85
}
86
86
87
87
let mir = cx. tcx . optimized_mir ( def_id. to_def_id ( ) ) ;
88
- let mir_read_only = mir. unwrap_read_only ( ) ;
89
88
90
89
let maybe_storage_live_result = MaybeStorageLive
91
90
. into_engine ( cx. tcx , mir, def_id. to_def_id ( ) )
92
91
. iterate_to_fixpoint ( )
93
92
. into_results_cursor ( mir) ;
94
93
let mut possible_borrower = {
95
94
let mut vis = PossibleBorrowerVisitor :: new ( cx, mir) ;
96
- vis. visit_body ( & mir_read_only ) ;
95
+ vis. visit_body ( & mir ) ;
97
96
vis. into_map ( cx, maybe_storage_live_result)
98
97
} ;
99
98
@@ -146,7 +145,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
146
145
// `arg` is a reference as it is `.deref()`ed in the previous block.
147
146
// Look into the predecessor block and find out the source of deref.
148
147
149
- let ps = mir_read_only . predecessors_for ( bb ) ;
148
+ let ps = & mir . predecessors ( ) [ bb ] ;
150
149
if ps. len ( ) != 1 {
151
150
continue ;
152
151
}
@@ -191,7 +190,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
191
190
( local, deref_clone_ret)
192
191
} ;
193
192
194
- let is_temp = mir_read_only . local_kind ( ret_local) == mir:: LocalKind :: Temp ;
193
+ let is_temp = mir . local_kind ( ret_local) == mir:: LocalKind :: Temp ;
195
194
196
195
// 1. `local` can be moved out if it is not used later.
197
196
// 2. If `ret_local` is a temporary and is neither consumed nor mutated, we can remove this `clone`
0 commit comments