Skip to content

Commit 22226fa

Browse files
committed
Remove region from borrow place contexts
1 parent 7ab92cd commit 22226fa

File tree

20 files changed

+100
-105
lines changed

20 files changed

+100
-105
lines changed

src/librustc/mir/visit.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::hir::def_id::DefId;
22
use crate::ty::subst::SubstsRef;
3-
use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty};
3+
use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Ty};
44
use crate::mir::*;
55
use syntax_pos::Span;
66

@@ -147,14 +147,14 @@ macro_rules! make_mir_visitor {
147147

148148
fn visit_place(&mut self,
149149
place: & $($mutability)? Place<'tcx>,
150-
context: PlaceContext<'tcx>,
150+
context: PlaceContext,
151151
location: Location) {
152152
self.super_place(place, context, location);
153153
}
154154

155155
fn visit_projection(&mut self,
156156
place: & $($mutability)? PlaceProjection<'tcx>,
157-
context: PlaceContext<'tcx>,
157+
context: PlaceContext,
158158
location: Location) {
159159
self.super_projection(place, context, location);
160160
}
@@ -252,7 +252,7 @@ macro_rules! make_mir_visitor {
252252

253253
fn visit_local(&mut self,
254254
_local: & $($mutability)? Local,
255-
_context: PlaceContext<'tcx>,
255+
_context: PlaceContext,
256256
_location: Location) {
257257
}
258258

@@ -576,16 +576,16 @@ macro_rules! make_mir_visitor {
576576
self.visit_region(r, location);
577577
let ctx = match bk {
578578
BorrowKind::Shared => PlaceContext::NonMutatingUse(
579-
NonMutatingUseContext::SharedBorrow(*r)
579+
NonMutatingUseContext::SharedBorrow
580580
),
581581
BorrowKind::Shallow => PlaceContext::NonMutatingUse(
582-
NonMutatingUseContext::ShallowBorrow(*r)
582+
NonMutatingUseContext::ShallowBorrow
583583
),
584584
BorrowKind::Unique => PlaceContext::NonMutatingUse(
585-
NonMutatingUseContext::UniqueBorrow(*r)
585+
NonMutatingUseContext::UniqueBorrow
586586
),
587587
BorrowKind::Mut { .. } =>
588-
PlaceContext::MutatingUse(MutatingUseContext::Borrow(*r)),
588+
PlaceContext::MutatingUse(MutatingUseContext::Borrow),
589589
};
590590
self.visit_place(path, ctx, location);
591591
}
@@ -716,7 +716,7 @@ macro_rules! make_mir_visitor {
716716

717717
fn super_place(&mut self,
718718
place: & $($mutability)? Place<'tcx>,
719-
context: PlaceContext<'tcx>,
719+
context: PlaceContext,
720720
location: Location) {
721721
match place {
722722
Place::Base(PlaceBase::Local(local)) => {
@@ -736,7 +736,7 @@ macro_rules! make_mir_visitor {
736736

737737
fn super_projection(&mut self,
738738
proj: & $($mutability)? PlaceProjection<'tcx>,
739-
context: PlaceContext<'tcx>,
739+
context: PlaceContext,
740740
location: Location) {
741741
let Projection { base, elem } = proj;
742742
let context = if context.is_mutating_use() {
@@ -948,19 +948,19 @@ pub enum TyContext {
948948
}
949949

950950
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
951-
pub enum NonMutatingUseContext<'tcx> {
951+
pub enum NonMutatingUseContext {
952952
/// Being inspected in some way, like loading a len.
953953
Inspect,
954954
/// Consumed as part of an operand.
955955
Copy,
956956
/// Consumed as part of an operand.
957957
Move,
958958
/// Shared borrow.
959-
SharedBorrow(Region<'tcx>),
959+
SharedBorrow,
960960
/// Shallow borrow.
961-
ShallowBorrow(Region<'tcx>),
961+
ShallowBorrow,
962962
/// Unique borrow.
963-
UniqueBorrow(Region<'tcx>),
963+
UniqueBorrow,
964964
/// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
965965
/// For example, the projection `x.y` is not marked as a mutation in these cases:
966966
///
@@ -971,7 +971,7 @@ pub enum NonMutatingUseContext<'tcx> {
971971
}
972972

973973
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
974-
pub enum MutatingUseContext<'tcx> {
974+
pub enum MutatingUseContext {
975975
/// Appears as LHS of an assignment.
976976
Store,
977977
/// Can often be treated as a `Store`, but needs to be separate because
@@ -983,7 +983,7 @@ pub enum MutatingUseContext<'tcx> {
983983
/// Being dropped.
984984
Drop,
985985
/// Mutable borrow.
986-
Borrow(Region<'tcx>),
986+
Borrow,
987987
/// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
988988
/// For example, the projection `x.y` is marked as a mutation in these cases:
989989
///
@@ -1006,13 +1006,13 @@ pub enum NonUseContext {
10061006
}
10071007

10081008
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1009-
pub enum PlaceContext<'tcx> {
1010-
NonMutatingUse(NonMutatingUseContext<'tcx>),
1011-
MutatingUse(MutatingUseContext<'tcx>),
1009+
pub enum PlaceContext {
1010+
NonMutatingUse(NonMutatingUseContext),
1011+
MutatingUse(MutatingUseContext),
10121012
NonUse(NonUseContext),
10131013
}
10141014

1015-
impl<'tcx> PlaceContext<'tcx> {
1015+
impl<'tcx> PlaceContext {
10161016
/// Returns `true` if this place context represents a drop.
10171017
pub fn is_drop(&self) -> bool {
10181018
match *self {
@@ -1024,10 +1024,10 @@ impl<'tcx> PlaceContext<'tcx> {
10241024
/// Returns `true` if this place context represents a borrow.
10251025
pub fn is_borrow(&self) -> bool {
10261026
match *self {
1027-
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
1028-
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
1029-
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
1030-
PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) => true,
1027+
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
1028+
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
1029+
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
1030+
PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
10311031
_ => false,
10321032
}
10331033
}

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
151151

152152
fn visit_place(&mut self,
153153
place: &mir::Place<'tcx>,
154-
context: PlaceContext<'tcx>,
154+
context: PlaceContext,
155155
location: Location) {
156156
debug!("visit_place(place={:?}, context={:?})", place, context);
157157
let cx = self.fx.cx;
@@ -203,7 +203,7 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
203203

204204
fn visit_local(&mut self,
205205
&local: &mir::Local,
206-
context: PlaceContext<'tcx>,
206+
context: PlaceContext,
207207
location: Location) {
208208
match context {
209209
PlaceContext::MutatingUse(MutatingUseContext::Call) => {
@@ -233,11 +233,11 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
233233
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
234234
PlaceContext::MutatingUse(MutatingUseContext::Store) |
235235
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) |
236-
PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) |
236+
PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
237237
PlaceContext::MutatingUse(MutatingUseContext::Projection) |
238-
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
239-
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
240-
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
238+
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
239+
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
240+
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
241241
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => {
242242
self.not_ssa(local);
243243
}

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl LocalsStateAtExit {
9595
struct HasStorageDead(BitSet<Local>);
9696

9797
impl<'tcx> Visitor<'tcx> for HasStorageDead {
98-
fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) {
98+
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _: Location) {
9999
if ctx == PlaceContext::NonUse(NonUseContext::StorageDead) {
100100
self.0.insert(*local);
101101
}
@@ -220,7 +220,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
220220
fn visit_local(
221221
&mut self,
222222
temp: &Local,
223-
context: PlaceContext<'tcx>,
223+
context: PlaceContext,
224224
location: Location,
225225
) {
226226
if !context.is_use() {

src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ enum DefUseResult {
113113
}
114114

115115
impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'gcx, 'tcx> {
116-
fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Location) {
116+
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
117117
let local_ty = self.mir.local_decls[local].ty;
118118

119119
let mut found_it = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl LocalUseMapBuild<'_> {
160160
}
161161

162162
impl Visitor<'tcx> for LocalUseMapBuild<'_> {
163-
fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, location: Location) {
163+
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
164164
if self.locals_with_use_data[local] {
165165
match categorize(context) {
166166
Some(DefUse::Def) => self.insert_def(local, location),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
269269
}
270270
}
271271

272-
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext<'_>, location: Location) {
272+
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
273273
self.sanitize_place(place, location, context);
274274
}
275275

@@ -447,7 +447,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
447447
&mut self,
448448
place: &Place<'tcx>,
449449
location: Location,
450-
context: PlaceContext<'_>,
450+
context: PlaceContext,
451451
) -> PlaceTy<'tcx> {
452452
debug!("sanitize_place: {:?}", place);
453453
let place_ty = match place {

src/librustc_mir/borrow_check/used_muts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'c
102102
fn visit_local(
103103
&mut self,
104104
local: &Local,
105-
place_context: PlaceContext<'tcx>,
105+
place_context: PlaceContext,
106106
location: Location,
107107
) {
108108
if place_context.is_place_assignment() && self.temporary_used_locals.contains(local) {

src/librustc_mir/monomorphize/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
658658

659659
fn visit_place(&mut self,
660660
place: &mir::Place<'tcx>,
661-
context: mir::visit::PlaceContext<'tcx>,
661+
context: mir::visit::PlaceContext,
662662
location: Location) {
663663
match place {
664664
Place::Base(

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
199199

200200
fn visit_place(&mut self,
201201
place: &Place<'tcx>,
202-
context: PlaceContext<'tcx>,
202+
context: PlaceContext,
203203
location: Location) {
204204
match place {
205205
&Place::Projection(box Projection {

src/librustc_mir/transform/const_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
510510
fn visit_local(
511511
&mut self,
512512
&local: &Local,
513-
context: PlaceContext<'tcx>,
513+
context: PlaceContext,
514514
_: Location,
515515
) {
516516
use rustc::mir::visit::PlaceContext::*;

0 commit comments

Comments
 (0)