X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Fborrow_check%2Fnll%2Ftype_check%2Fliveness.rs;h=0eb88b7bcbfd390d2ca8009f1fd5353c23bb43fd;hb=43b69c27771929e6dfa7bf1771bc8ee5ce7a99c5;hp=91025e3f4afc016e13e7d2048f1fd19baaccc06a;hpb=185fb7b77c4188dc882df8a15471d84f0ae74e57;p=rust.git diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index 91025e3f4af..0eb88b7bcbf 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -21,7 +21,7 @@ use rustc::ty::{Ty, TypeFoldable}; use rustc_data_structures::fx::FxHashMap; use std::rc::Rc; -use util::liveness::LivenessResults; +use util::liveness::{IdentityMap, LivenessResults}; use super::TypeChecker; @@ -36,7 +36,7 @@ pub(super) fn generate<'gcx, 'tcx>( cx: &mut TypeChecker<'_, 'gcx, 'tcx>, mir: &Mir<'tcx>, - liveness: &LivenessResults, + liveness: &LivenessResults, flow_inits: &mut FlowAtLocation>, move_data: &MoveData<'tcx>, ) { @@ -47,6 +47,7 @@ pub(super) fn generate<'gcx, 'tcx>( flow_inits, move_data, drop_data: FxHashMap(), + map: &IdentityMap::new(mir), }; for bb in mir.basic_blocks().indices() { @@ -63,10 +64,11 @@ struct TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx> { cx: &'gen mut TypeChecker<'typeck, 'gcx, 'tcx>, mir: &'gen Mir<'tcx>, - liveness: &'gen LivenessResults, + liveness: &'gen LivenessResults, flow_inits: &'gen mut FlowAtLocation>, move_data: &'gen MoveData<'tcx>, drop_data: FxHashMap, DropData<'tcx>>, + map: &'gen IdentityMap<'gen, 'tcx>, } struct DropData<'tcx> { @@ -84,7 +86,7 @@ fn add_liveness_constraints(&mut self, bb: BasicBlock) { self.liveness .regular - .simulate_block(self.mir, bb, |location, live_locals| { + .simulate_block(self.mir, bb, self.map, |location, live_locals| { for live_local in live_locals.iter() { let live_local_ty = self.mir.local_decls[live_local].ty; Self::push_type_live_constraint(&mut self.cx, live_local_ty, location); @@ -94,7 +96,7 @@ fn add_liveness_constraints(&mut self, bb: BasicBlock) { let mut all_live_locals: Vec<(Location, Vec)> = vec![]; self.liveness .drop - .simulate_block(self.mir, bb, |location, live_locals| { + .simulate_block(self.mir, bb, self.map, |location, live_locals| { all_live_locals.push((location, live_locals.iter().collect())); }); debug!( @@ -168,7 +170,18 @@ fn push_type_live_constraint( ); cx.tcx().for_each_free_region(&value, |live_region| { - cx.constraints.liveness_set.push((live_region, location)); + if let Some(ref mut borrowck_context) = cx.borrowck_context { + let region_vid = borrowck_context.universal_regions.to_region_vid(live_region); + borrowck_context.constraints.liveness_constraints.add_element(region_vid, location); + + if let Some(all_facts) = borrowck_context.all_facts { + let start_index = borrowck_context.location_table.start_index(location); + all_facts.region_live_at.push((region_vid, start_index)); + + let mid_index = borrowck_context.location_table.mid_index(location); + all_facts.region_live_at.push((region_vid, mid_index)); + } + } }); }