@@ -6,6 +6,7 @@ use rustc_lint::LateContext;
6
6
use rustc_middle:: mir:: { self , visit:: Visitor as _, Mutability } ;
7
7
use rustc_middle:: ty:: { self , visit:: TypeVisitor } ;
8
8
use rustc_mir_dataflow:: { impls:: MaybeStorageLive , Analysis , ResultsCursor } ;
9
+ use std:: borrow:: Cow ;
9
10
use std:: ops:: ControlFlow ;
10
11
11
12
/// Collects the possible borrowers of each local.
@@ -36,7 +37,7 @@ impl<'a, 'b, 'tcx> PossibleBorrowerVisitor<'a, 'b, 'tcx> {
36
37
fn into_map (
37
38
self ,
38
39
cx : & ' a LateContext < ' tcx > ,
39
- maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive > ,
40
+ maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive < ' tcx > > ,
40
41
) -> PossibleBorrowerMap < ' b , ' tcx > {
41
42
let mut map = FxHashMap :: default ( ) ;
42
43
for row in ( 1 ..self . body . local_decls . len ( ) ) . map ( mir:: Local :: from_usize) {
@@ -167,7 +168,7 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) {
167
168
pub struct PossibleBorrowerMap < ' b , ' tcx > {
168
169
/// Mapping `Local -> its possible borrowers`
169
170
pub map : FxHashMap < mir:: Local , HybridBitSet < mir:: Local > > ,
170
- maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive > ,
171
+ maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive < ' tcx > > ,
171
172
// Caches to avoid allocation of `BitSet` on every query
172
173
pub bitset : ( BitSet < mir:: Local > , BitSet < mir:: Local > ) ,
173
174
}
@@ -179,7 +180,7 @@ impl<'a, 'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
179
180
vis. visit_body ( mir) ;
180
181
vis. into_map ( cx)
181
182
} ;
182
- let maybe_storage_live_result = MaybeStorageLive :: new ( BitSet :: new_empty ( mir. local_decls . len ( ) ) )
183
+ let maybe_storage_live_result = MaybeStorageLive :: new ( Cow :: Owned ( BitSet :: new_empty ( mir. local_decls . len ( ) ) ) )
183
184
. into_engine ( cx. tcx , mir)
184
185
. pass_name ( "redundant_clone" )
185
186
. iterate_to_fixpoint ( )
0 commit comments