@@ -16,6 +16,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
16
16
use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex } ;
17
17
use rustc_mir_dataflow:: ResultsCursor ;
18
18
19
+ use crate :: location:: RichLocation ;
19
20
use crate :: {
20
21
region_infer:: values:: { self , LiveLoans } ,
21
22
type_check:: liveness:: local_use_map:: LocalUseMap ,
@@ -46,7 +47,6 @@ pub(super) fn trace<'mir, 'tcx>(
46
47
move_data : & MoveData < ' tcx > ,
47
48
relevant_live_locals : Vec < Local > ,
48
49
boring_locals : Vec < Local > ,
49
- polonius_drop_used : Option < Vec < ( Local , Location ) > > ,
50
50
) {
51
51
let local_use_map = & LocalUseMap :: build ( & relevant_live_locals, elements, body) ;
52
52
@@ -93,9 +93,7 @@ pub(super) fn trace<'mir, 'tcx>(
93
93
94
94
let mut results = LivenessResults :: new ( cx) ;
95
95
96
- if let Some ( drop_used) = polonius_drop_used {
97
- results. add_extra_drop_facts ( drop_used, relevant_live_locals. iter ( ) . copied ( ) . collect ( ) )
98
- }
96
+ results. add_extra_drop_facts ( & relevant_live_locals) ;
99
97
100
98
results. compute_for_all_locals ( relevant_live_locals) ;
101
99
@@ -218,21 +216,38 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
218
216
///
219
217
/// Add facts for all locals with free regions, since regions may outlive
220
218
/// the function body only at certain nodes in the CFG.
221
- fn add_extra_drop_facts (
222
- & mut self ,
223
- drop_used : Vec < ( Local , Location ) > ,
224
- relevant_live_locals : FxIndexSet < Local > ,
225
- ) {
219
+ fn add_extra_drop_facts ( & mut self , relevant_live_locals : & [ Local ] ) -> Option < ( ) > {
220
+ let drop_used = self
221
+ . cx
222
+ . typeck
223
+ . borrowck_context
224
+ . all_facts
225
+ . as_ref ( )
226
+ . map ( |facts| facts. var_dropped_at . clone ( ) ) ?;
227
+
228
+ let relevant_live_locals: FxIndexSet < _ > = relevant_live_locals. iter ( ) . copied ( ) . collect ( ) ;
229
+
226
230
let locations = IntervalSet :: new ( self . cx . elements . num_points ( ) ) ;
227
231
228
- for ( local, location ) in drop_used {
232
+ for ( local, location_index ) in drop_used {
229
233
if !relevant_live_locals. contains ( & local) {
230
234
let local_ty = self . cx . body . local_decls [ local] . ty ;
231
235
if local_ty. has_free_regions ( ) {
236
+ let location = match self
237
+ . cx
238
+ . typeck
239
+ . borrowck_context
240
+ . location_table
241
+ . to_location ( location_index)
242
+ {
243
+ RichLocation :: Start ( l) => l,
244
+ RichLocation :: Mid ( l) => l,
245
+ } ;
232
246
self . cx . add_drop_live_facts_for ( local, local_ty, & [ location] , & locations) ;
233
247
}
234
248
}
235
249
}
250
+ Some ( ( ) )
236
251
}
237
252
238
253
/// Clear the value of fields that are "per local variable".
0 commit comments