From 0819ba9bea742dcc484a939710952a9840c8fae8 Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Thu, 19 Jul 2018 00:14:32 +0530 Subject: [PATCH] mir/mod.rs / visit.rs reverted back to using Local --- src/librustc/mir/mod.rs | 18 +++++++++--------- src/librustc/mir/visit.rs | 10 +++++----- src/librustc_mir/borrow_check/mod.rs | 2 +- .../borrow_check/nll/type_check/liveness.rs | 2 +- .../dataflow/impls/borrowed_locals.rs | 14 +++++++------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 18b3cf991d8b..e19d2b9f1812 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -52,7 +52,7 @@ pub mod traversal; pub mod visit; /// Types for locals -type LocalDecls<'tcx> = IndexVec>; +type LocalDecls<'tcx> = IndexVec>; pub trait HasLocalDecls<'tcx> { fn local_decls(&self) -> &LocalDecls<'tcx>; @@ -141,7 +141,7 @@ impl<'tcx> Mir<'tcx> { source_scope_local_data: ClearCrossCrate>, promoted: IndexVec>, yield_ty: Option>, - local_decls: IndexVec>, + local_decls: IndexVec>, arg_count: usize, upvar_decls: Vec, span: Span, @@ -209,7 +209,7 @@ impl<'tcx> Mir<'tcx> { } #[inline] - pub fn local_kind(&self, local: LocalWithRegion) -> LocalKind { + pub fn local_kind(&self, local: Local) -> LocalKind { let index = local.0 as usize; if index == 0 { debug_assert!( @@ -234,9 +234,9 @@ impl<'tcx> Mir<'tcx> { /// Returns an iterator over all temporaries. #[inline] - pub fn temps_iter<'a>(&'a self) -> impl Iterator + 'a { + pub fn temps_iter<'a>(&'a self) -> impl Iterator + 'a { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { - let local = LocalWithRegion::new(index); + let local = Local::new(index); if self.local_decls[local].is_user_variable.is_some() { None } else { @@ -247,9 +247,9 @@ impl<'tcx> Mir<'tcx> { /// Returns an iterator over all user-declared locals. #[inline] - pub fn vars_iter<'a>(&'a self) -> impl Iterator + 'a { + pub fn vars_iter<'a>(&'a self) -> impl Iterator + 'a { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { - let local = LocalWithRegion::new(index); + let local = Local::new(index); if self.local_decls[local].is_user_variable.is_some() { Some(local) } else { @@ -260,9 +260,9 @@ impl<'tcx> Mir<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator + 'a { + pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator + 'a { (1..self.local_decls.len()).filter_map(move |index| { - let local = LocalWithRegion::new(index); + let local = Local::new(index); let decl = &self.local_decls[local]; if (decl.is_user_variable.is_some() || index < self.arg_count + 1) && decl.mutability == Mutability::Mut diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index ced185d132a7..758d887cd7b3 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -146,7 +146,7 @@ macro_rules! make_mir_visitor { fn visit_user_assert_ty(&mut self, c_ty: & $($mutability)* CanonicalTy<'tcx>, - local: & $($mutability)* LocalWithRegion, + local: & $($mutability)* Local, location: Location) { self.super_user_assert_ty(c_ty, local, location); } @@ -250,13 +250,13 @@ macro_rules! make_mir_visitor { } fn visit_local_decl(&mut self, - local: LocalWithRegion, + local: Local, local_decl: & $($mutability)* LocalDecl<'tcx>) { self.super_local_decl(local, local_decl); } fn visit_local(&mut self, - _local: & $($mutability)* LocalWithRegion, + _local: & $($mutability)* Local, _context: PlaceContext<'tcx>, _location: Location) { } @@ -632,7 +632,7 @@ macro_rules! make_mir_visitor { fn super_user_assert_ty(&mut self, _c_ty: & $($mutability)* CanonicalTy<'tcx>, - local: & $($mutability)* LocalWithRegion, + local: & $($mutability)* Local, location: Location) { self.visit_local(local, PlaceContext::Validate, location); } @@ -708,7 +708,7 @@ macro_rules! make_mir_visitor { } fn super_local_decl(&mut self, - local: LocalWithRegion, + local: Local, local_decl: & $($mutability)* LocalDecl<'tcx>) { let LocalDecl { mutability: _, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index ae539f43957c..e7f00b577b39 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -278,7 +278,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( // Note that this set is expected to be small - only upvars from closures // would have a chance of erroneously adding non-user-defined mutable vars // to the set. - let temporary_used_locals: FxHashSet = mbcx + let temporary_used_locals: FxHashSet = mbcx .used_mut .iter() .filter(|&local| !mbcx.mir.local_decls[*local].is_user_variable.is_some()) 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 17cc99c55226..675c7f24e653 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -192,7 +192,7 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo /// particular this takes `#[may_dangle]` into account. fn add_drop_live_constraint( &mut self, - dropped_local: Local, + dropped_local: LocalWithRegion, dropped_ty: Ty<'tcx>, location: Location, ) { diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index 9cfddb5b3204..c7513ac88163 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -37,18 +37,18 @@ impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> { } impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> { - type Idx = LocalWithRegion; + type Idx = Local; fn name() -> &'static str { "has_been_borrowed_locals" } fn bits_per_block(&self) -> usize { self.mir.local_decls.len() } - fn start_block_effect(&self, _sets: &mut IdxSet) { + fn start_block_effect(&self, _sets: &mut IdxSet) { // Nothing is borrowed on function entry } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets, loc: Location) { BorrowedLocalsVisitor { sets, @@ -56,7 +56,7 @@ impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> { } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets, loc: Location) { BorrowedLocalsVisitor { sets, @@ -64,7 +64,7 @@ impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> { } fn propagate_call_return(&self, - _in_out: &mut IdxSet, + _in_out: &mut IdxSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, _dest_place: &mir::Place) { @@ -87,10 +87,10 @@ impl<'a, 'tcx> InitialFlow for HaveBeenBorrowedLocals<'a, 'tcx> { } struct BorrowedLocalsVisitor<'b, 'c: 'b> { - sets: &'b mut BlockSets<'c, LocalWithRegion>, + sets: &'b mut BlockSets<'c, Local>, } -fn find_local<'tcx>(place: &Place<'tcx>) -> Option { +fn find_local<'tcx>(place: &Place<'tcx>) -> Option { match *place { Place::Local(l) => Some(l), Place::Static(..) => None,