@@ -16,6 +16,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1616use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex } ;
1717use rustc_mir_dataflow:: ResultsCursor ;
1818
19+ use crate :: location:: RichLocation ;
1920use crate :: {
2021 region_infer:: values:: { self , LiveLoans } ,
2122 type_check:: liveness:: local_use_map:: LocalUseMap ,
@@ -46,7 +47,6 @@ pub(super) fn trace<'mir, 'tcx>(
4647 move_data : & MoveData < ' tcx > ,
4748 relevant_live_locals : Vec < Local > ,
4849 boring_locals : Vec < Local > ,
49- polonius_drop_used : Option < Vec < ( Local , Location ) > > ,
5050) {
5151 let local_use_map = & LocalUseMap :: build ( & relevant_live_locals, elements, body) ;
5252
@@ -93,9 +93,7 @@ pub(super) fn trace<'mir, 'tcx>(
9393
9494 let mut results = LivenessResults :: new ( cx) ;
9595
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) ;
9997
10098 results. compute_for_all_locals ( relevant_live_locals) ;
10199
@@ -218,21 +216,38 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
218216 ///
219217 /// Add facts for all locals with free regions, since regions may outlive
220218 /// 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+
226230 let locations = IntervalSet :: new ( self . cx . elements . num_points ( ) ) ;
227231
228- for ( local, location ) in drop_used {
232+ for ( local, location_index ) in drop_used {
229233 if !relevant_live_locals. contains ( & local) {
230234 let local_ty = self . cx . body . local_decls [ local] . ty ;
231235 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+ } ;
232246 self . cx . add_drop_live_facts_for ( local, local_ty, & [ location] , & locations) ;
233247 }
234248 }
235249 }
250+ Some ( ( ) )
236251 }
237252
238253 /// Clear the value of fields that are "per local variable".
0 commit comments