mir/mod.rs / visit.rs reverted back to using Local
This commit is contained in:
parent
0d847ec1ab
commit
0819ba9bea
5 changed files with 23 additions and 23 deletions
|
|
@ -52,7 +52,7 @@ pub mod traversal;
|
|||
pub mod visit;
|
||||
|
||||
/// Types for locals
|
||||
type LocalDecls<'tcx> = IndexVec<LocalWithRegion, LocalDecl<'tcx>>;
|
||||
type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>;
|
||||
|
||||
pub trait HasLocalDecls<'tcx> {
|
||||
fn local_decls(&self) -> &LocalDecls<'tcx>;
|
||||
|
|
@ -141,7 +141,7 @@ impl<'tcx> Mir<'tcx> {
|
|||
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
yield_ty: Option<Ty<'tcx>>,
|
||||
local_decls: IndexVec<LocalWithRegion, LocalDecl<'tcx>>,
|
||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
arg_count: usize,
|
||||
upvar_decls: Vec<UpvarDecl>,
|
||||
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<Item = LocalWithRegion> + 'a {
|
||||
pub fn temps_iter<'a>(&'a self) -> impl Iterator<Item = Local> + '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<Item = LocalWithRegion> + 'a {
|
||||
pub fn vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + '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<Item = LocalWithRegion> + 'a {
|
||||
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + '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
|
||||
|
|
|
|||
|
|
@ -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: _,
|
||||
|
|
|
|||
|
|
@ -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<LocalWithRegion> = mbcx
|
||||
let temporary_used_locals: FxHashSet<Local> = mbcx
|
||||
.used_mut
|
||||
.iter()
|
||||
.filter(|&local| !mbcx.mir.local_decls[*local].is_user_variable.is_some())
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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<LocalWithRegion>) {
|
||||
fn start_block_effect(&self, _sets: &mut IdxSet<Local>) {
|
||||
// Nothing is borrowed on function entry
|
||||
}
|
||||
|
||||
fn statement_effect(&self,
|
||||
sets: &mut BlockSets<LocalWithRegion>,
|
||||
sets: &mut BlockSets<Local>,
|
||||
loc: Location) {
|
||||
BorrowedLocalsVisitor {
|
||||
sets,
|
||||
|
|
@ -56,7 +56,7 @@ impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn terminator_effect(&self,
|
||||
sets: &mut BlockSets<LocalWithRegion>,
|
||||
sets: &mut BlockSets<Local>,
|
||||
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<LocalWithRegion>,
|
||||
_in_out: &mut IdxSet<Local>,
|
||||
_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<LocalWithRegion> {
|
||||
fn find_local<'tcx>(place: &Place<'tcx>) -> Option<Local> {
|
||||
match *place {
|
||||
Place::Local(l) => Some(l),
|
||||
Place::Static(..) => None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue