Skip to content

Commit 1951a30

Browse files
committed
convert LocalWithRegion to Local
1 parent 0819ba9 commit 1951a30

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::path::PathBuf;
3030
use std::rc::Rc;
3131
use std::str::FromStr;
3232
use transform::MirSource;
33-
use util::liveness::{IdentityMap, LivenessResults, LocalSet, NllLivenessMap};
33+
use util::liveness::{LivenessResults, LocalSet, NllLivenessMap};
3434

3535
use self::mir_util::PassWhere;
3636
use polonius_engine::{Algorithm, Output};
@@ -220,7 +220,7 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
220220
return;
221221
}
222222

223-
let map = &IdentityMap::new(mir);
223+
let map = &NllLivenessMap::compute(mir);
224224

225225
let regular_liveness_per_location: FxHashMap<_, _> = mir
226226
.basic_blocks()

src/librustc_mir/borrow_check/nll/type_check/liveness.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use dataflow::move_paths::{HasMoveData, MoveData};
1313
use dataflow::MaybeInitializedPlaces;
1414
use dataflow::{FlowAtLocation, FlowsAtLocation};
1515
use rustc::infer::canonical::QueryRegionConstraint;
16-
use rustc::mir::{Local, LocalWithRegion};
16+
use rustc::mir::LocalWithRegion;
1717
use rustc::mir::{BasicBlock, Location, Mir};
1818
use rustc::traits::query::dropck_outlives::DropckOutlivesResult;
1919
use rustc::traits::query::type_op::outlives::DropckOutlives;
2020
use rustc::traits::query::type_op::TypeOp;
2121
use rustc::ty::{Ty, TypeFoldable};
2222
use rustc_data_structures::fx::FxHashMap;
2323
use std::rc::Rc;
24-
use util::liveness::{IdentityMap, LivenessResults};
24+
use util::liveness::{NllLivenessMap, LivenessResults, LiveVariableMap };
2525

2626
use super::TypeChecker;
2727

@@ -47,7 +47,7 @@ pub(super) fn generate<'gcx, 'tcx>(
4747
flow_inits,
4848
move_data,
4949
drop_data: FxHashMap(),
50-
map: &IdentityMap::new(mir),
50+
map: &NllLivenessMap::compute(mir),
5151
};
5252

5353
for bb in mir.basic_blocks().indices() {
@@ -68,7 +68,7 @@ where
6868
flow_inits: &'gen mut FlowAtLocation<MaybeInitializedPlaces<'flow, 'gcx, 'tcx>>,
6969
move_data: &'gen MoveData<'tcx>,
7070
drop_data: FxHashMap<Ty<'tcx>, DropData<'tcx>>,
71-
map: &'gen IdentityMap<'gen, 'tcx>,
71+
map: &'gen NllLivenessMap,
7272
}
7373

7474
struct DropData<'tcx> {
@@ -88,7 +88,8 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
8888
.regular
8989
.simulate_block(self.mir, bb, self.map, |location, live_locals| {
9090
for live_local in live_locals.iter() {
91-
let live_local_ty = self.mir.local_decls[live_local].ty;
91+
let local = self.map.from_live_var(live_local);
92+
let live_local_ty = self.mir.local_decls[local].ty;
9293
Self::push_type_live_constraint(&mut self.cx, live_local_ty, location);
9394
}
9495
});
@@ -123,15 +124,17 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
123124
});
124125
}
125126

126-
let mpi = self.move_data.rev_lookup.find_local(live_local);
127+
let local = self.map.from_live_var(live_local);
128+
let mpi = self.move_data.rev_lookup.find_local(local);
127129
if let Some(initialized_child) = self.flow_inits.has_any_child_of(mpi) {
128130
debug!(
129131
"add_liveness_constraints: mpi={:?} has initialized child {:?}",
130132
self.move_data.move_paths[mpi],
131133
self.move_data.move_paths[initialized_child]
132134
);
133135

134-
let live_local_ty = self.mir.local_decls[live_local].ty;
136+
let local = self.map.from_live_var(live_local);
137+
let live_local_ty = self.mir.local_decls[local].ty;
135138
self.add_drop_live_constraint(live_local, live_local_ty, location);
136139
}
137140
}

src/librustc_mir/util/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl LiveVariableMap for NllLivenessMap {
570570
impl NllLivenessMap {
571571
pub fn compute(mir: &Mir) -> Self {
572572
let mut to_local = IndexVec::default();
573-
let from_local: IndexVec<_,_> = mir.local.decls.iter_enumerated.map(|local, local_decl| {
573+
let from_local: IndexVec<Local,Option<_>> = mir.local_decls.iter_enumerated().map(|(local, local_decl)| {
574574
if local_decl.ty.has_free_regions() {
575575
Some(to_local.push(local))
576576
}

0 commit comments

Comments
 (0)