Skip to content

Commit f2b5583

Browse files
committed
add trait structs and other changes from V to local
1 parent 38c7d1a commit f2b5583

File tree

4 files changed

+84
-56
lines changed

4 files changed

+84
-56
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use dataflow::FlowAtLocation;
1919
use dataflow::MaybeInitializedPlaces;
2020
use rustc::hir::def_id::DefId;
2121
use rustc::infer::InferCtxt;
22-
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir};
22+
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir, Local};
2323
use rustc::ty::{self, RegionKind, RegionVid};
2424
use rustc::util::nodemap::FxHashMap;
2525
use rustc_data_structures::indexed_vec::Idx;
@@ -208,9 +208,9 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
208208
(regioncx, polonius_output, closure_region_requirements)
209209
}
210210

211-
fn dump_mir_results<'a, 'gcx, 'tcx, V: Idx>(
211+
fn dump_mir_results<'a, 'gcx, 'tcx>(
212212
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
213-
liveness: &LivenessResults<V>,
213+
liveness: &LivenessResults<Local>,
214214
source: MirSource,
215215
mir: &Mir<'tcx>,
216216
regioncx: &RegionInferenceContext,
@@ -406,7 +406,7 @@ impl ToRegionVid for RegionVid {
406406
}
407407
}
408408

409-
fn live_variable_set<V: Idx>(regular: &LocalSet<V>, drops: &LocalSet<V>) -> String {
409+
fn live_variable_set(regular: &LocalSet<Local>, drops: &LocalSet<Local>) -> String {
410410
// sort and deduplicate:
411411
let all_locals: BTreeSet<_> = regular.iter().chain(drops.iter()).collect();
412412

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ use super::TypeChecker;
3434
///
3535
/// NB. This computation requires normalization; therefore, it must be
3636
/// performed before
37-
pub(super) fn generate<'gcx, 'tcx, V: Idx>(
37+
pub(super) fn generate<'gcx, 'tcx>(
3838
cx: &mut TypeChecker<'_, 'gcx, 'tcx>,
3939
mir: &Mir<'tcx>,
40-
liveness: &LivenessResults<V>,
40+
liveness: &LivenessResults<Local>,
4141
flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
4242
move_data: &MoveData<'tcx>,
4343
) {
@@ -55,17 +55,16 @@ pub(super) fn generate<'gcx, 'tcx, V: Idx>(
5555
}
5656
}
5757

58-
struct TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx, V>
58+
struct TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx>
5959
where
6060
'typeck: 'gen,
6161
'flow: 'gen,
6262
'tcx: 'typeck + 'flow,
6363
'gcx: 'tcx,
64-
V: Idx + 'gen,
6564
{
6665
cx: &'gen mut TypeChecker<'typeck, 'gcx, 'tcx>,
6766
mir: &'gen Mir<'tcx>,
68-
liveness: &'gen LivenessResults<V>,
67+
liveness: &'gen LivenessResults<Local>,
6968
flow_inits: &'gen mut FlowAtLocation<MaybeInitializedPlaces<'flow, 'gcx, 'tcx>>,
7069
move_data: &'gen MoveData<'tcx>,
7170
drop_data: FxHashMap<Ty<'tcx>, DropData<'tcx>>,
@@ -76,7 +75,7 @@ struct DropData<'tcx> {
7675
region_constraint_data: Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>,
7776
}
7877

79-
impl<'gen, 'typeck, 'flow, 'gcx, 'tcx, V: Idx> TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx, V> {
78+
impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flow, 'gcx, 'tcx> {
8079
/// Liveness constraints:
8180
///
8281
/// > If a variable V is live at point P, then all regions R in the type of V

src/librustc_mir/transform/generator.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ fn self_arg() -> Local {
126126
Local::new(1)
127127
}
128128

129-
struct SuspensionPoint<V: Idx> {
129+
struct SuspensionPoint {
130130
state: u32,
131131
resume: BasicBlock,
132132
drop: Option<BasicBlock>,
133-
storage_liveness: liveness::LocalSet<V>,
133+
storage_liveness: liveness::LocalSet<Local>,
134134
}
135135

136-
struct TransformVisitor<'a, 'tcx: 'a, V: Idx> {
136+
struct TransformVisitor<'a, 'tcx: 'a> {
137137
tcx: TyCtxt<'a, 'tcx, 'tcx>,
138138
state_adt_ref: &'tcx AdtDef,
139139
state_substs: &'tcx Substs<'tcx>,
@@ -145,16 +145,16 @@ struct TransformVisitor<'a, 'tcx: 'a, V: Idx> {
145145
remap: HashMap<Local, (Ty<'tcx>, usize)>,
146146

147147
// A map from a suspension point in a block to the locals which have live storage at that point
148-
storage_liveness: HashMap<BasicBlock, liveness::LocalSet<V>>,
148+
storage_liveness: HashMap<BasicBlock, liveness::LocalSet<Local>>,
149149

150150
// A list of suspension points, generated during the transform
151-
suspension_points: Vec<SuspensionPoint<V>>,
151+
suspension_points: Vec<SuspensionPoint>,
152152

153153
// The original RETURN_PLACE local
154154
new_ret_local: Local,
155155
}
156156

157-
impl<'a, 'tcx, V: Idx> TransformVisitor<'a, 'tcx, V> {
157+
impl<'a, 'tcx> TransformVisitor<'a, 'tcx> {
158158
// Make a GeneratorState rvalue
159159
fn make_state(&self, idx: usize, val: Operand<'tcx>) -> Rvalue<'tcx> {
160160
let adt = AggregateKind::Adt(self.state_adt_ref, idx, self.state_substs, None);
@@ -191,7 +191,7 @@ impl<'a, 'tcx, V: Idx> TransformVisitor<'a, 'tcx, V> {
191191
}
192192
}
193193

194-
impl<'a, 'tcx, V: Idx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx, V> {
194+
impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> {
195195
fn visit_local(&mut self,
196196
local: &mut Local,
197197
_: PlaceContext<'tcx>,
@@ -317,9 +317,9 @@ fn replace_result_variable<'tcx>(ret_ty: Ty<'tcx>,
317317
new_ret_local
318318
}
319319

320-
struct StorageIgnored<V: Idx>(liveness::LocalSet<V>);
320+
struct StorageIgnored(liveness::LocalSet<Local>);
321321

322-
impl<'tcx, V: Idx> Visitor<'tcx> for StorageIgnored<V> {
322+
impl<'tcx> Visitor<'tcx> for StorageIgnored {
323323
fn visit_statement(&mut self,
324324
_block: BasicBlock,
325325
statement: &Statement<'tcx>,
@@ -332,9 +332,9 @@ impl<'tcx, V: Idx> Visitor<'tcx> for StorageIgnored<V> {
332332
}
333333
}
334334

335-
struct BorrowedLocals<V: Idx>(liveness::LocalSet<V>);
335+
struct BorrowedLocals(liveness::LocalSet<Local>);
336336

337-
fn mark_as_borrowed<'tcx, V: Idx>(place: &Place<'tcx>, locals: &mut BorrowedLocals<V>) {
337+
fn mark_as_borrowed<'tcx, V: Idx>(place: &Place<'tcx>, locals: &mut BorrowedLocals) {
338338
match *place {
339339
Place::Local(l) => { locals.0.add(&l); },
340340
Place::Static(..) => (),
@@ -349,7 +349,7 @@ fn mark_as_borrowed<'tcx, V: Idx>(place: &Place<'tcx>, locals: &mut BorrowedLoca
349349
}
350350
}
351351

352-
impl<'tcx, V: Idx> Visitor<'tcx> for BorrowedLocals<V> {
352+
impl<'tcx> Visitor<'tcx> for BorrowedLocals {
353353
fn visit_rvalue(&mut self,
354354
rvalue: &Rvalue<'tcx>,
355355
location: Location) {
@@ -361,12 +361,12 @@ impl<'tcx, V: Idx> Visitor<'tcx> for BorrowedLocals<V> {
361361
}
362362
}
363363

364-
fn locals_live_across_suspend_points<'a, 'tcx, V: Idx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
364+
fn locals_live_across_suspend_points<'a, 'tcx,>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
365365
mir: &Mir<'tcx>,
366366
source: MirSource,
367367
movable: bool) ->
368-
(liveness::LocalSet<V>,
369-
HashMap<BasicBlock, liveness::LocalSet<V>>) {
368+
(liveness::LocalSet<Local>,
369+
HashMap<BasicBlock, liveness::LocalSet<Local>>) {
370370
let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());
371371
let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap();
372372

@@ -460,15 +460,15 @@ fn locals_live_across_suspend_points<'a, 'tcx, V: Idx>(tcx: TyCtxt<'a, 'tcx, 'tc
460460
(set, storage_liveness_map)
461461
}
462462

463-
fn compute_layout<'a, 'tcx, V: Idx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
463+
fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
464464
source: MirSource,
465465
upvars: Vec<Ty<'tcx>>,
466466
interior: Ty<'tcx>,
467467
movable: bool,
468468
mir: &mut Mir<'tcx>)
469469
-> (HashMap<Local, (Ty<'tcx>, usize)>,
470470
GeneratorLayout<'tcx>,
471-
HashMap<BasicBlock, liveness::LocalSet<V>>)
471+
HashMap<BasicBlock, liveness::LocalSet<Local>>)
472472
{
473473
// Use a liveness analysis to compute locals which are live across a suspension point
474474
let (live_locals, storage_liveness) = locals_live_across_suspend_points(tcx,
@@ -524,10 +524,10 @@ fn compute_layout<'a, 'tcx, V: Idx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
524524
(remap, layout, storage_liveness)
525525
}
526526

527-
fn insert_switch<'a, 'tcx, V: Idx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
527+
fn insert_switch<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
528528
mir: &mut Mir<'tcx>,
529529
cases: Vec<(u32, BasicBlock)>,
530-
transform: &TransformVisitor<'a, 'tcx, V>,
530+
transform: &TransformVisitor<'a, 'tcx>,
531531
default: TerminatorKind<'tcx>) {
532532
let default_block = insert_term_block(mir, default);
533533

@@ -608,9 +608,9 @@ fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
608608
}
609609
}
610610

611-
fn create_generator_drop_shim<'a, 'tcx, V: Idx>(
611+
fn create_generator_drop_shim<'a, 'tcx>(
612612
tcx: TyCtxt<'a, 'tcx, 'tcx>,
613-
transform: &TransformVisitor<'a, 'tcx, V>,
613+
transform: &TransformVisitor<'a, 'tcx>,
614614
def_id: DefId,
615615
source: MirSource,
616616
gen_ty: Ty<'tcx>,
@@ -719,9 +719,9 @@ fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
719719
assert_block
720720
}
721721

722-
fn create_generator_resume_function<'a, 'tcx, V: Idx>(
722+
fn create_generator_resume_function<'a, 'tcx>(
723723
tcx: TyCtxt<'a, 'tcx, 'tcx>,
724-
transform: TransformVisitor<'a, 'tcx, V>,
724+
transform: TransformVisitor<'a, 'tcx>,
725725
def_id: DefId,
726726
source: MirSource,
727727
mir: &mut Mir<'tcx>) {
@@ -790,10 +790,10 @@ fn insert_clean_drop<'a, 'tcx>(mir: &mut Mir<'tcx>) -> BasicBlock {
790790
drop_clean
791791
}
792792

793-
fn create_cases<'a, 'tcx, F, V: Idx>(mir: &mut Mir<'tcx>,
794-
transform: &TransformVisitor<'a, 'tcx, V>,
793+
fn create_cases<'a, 'tcx, F>(mir: &mut Mir<'tcx>,
794+
transform: &TransformVisitor<'a, 'tcx>,
795795
target: F) -> Vec<(u32, BasicBlock)>
796-
where F: Fn(&SuspensionPoint<V>) -> Option<BasicBlock> {
796+
where F: Fn(&SuspensionPoint) -> Option<BasicBlock> {
797797
let source_info = source_info(mir);
798798

799799
transform.suspension_points.iter().filter_map(|point| {

0 commit comments

Comments
 (0)