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::*;

src/librustc_mir/transform/copy_prop.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ impl MirPass for CopyPropagation {
134134
}
135135
}
136136

137-
fn eliminate_self_assignments<'tcx>(
138-
mir: &mut Mir<'tcx>,
139-
def_use_analysis: &DefUseAnalysis<'tcx>,
137+
fn eliminate_self_assignments(
138+
mir: &mut Mir<'_>,
139+
def_use_analysis: &DefUseAnalysis,
140140
) -> bool {
141141
let mut changed = false;
142142

@@ -177,7 +177,7 @@ enum Action<'tcx> {
177177
}
178178

179179
impl<'tcx> Action<'tcx> {
180-
fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis<'_>, src_place: &Place<'tcx>)
180+
fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>)
181181
-> Option<Action<'tcx>> {
182182
// The source must be a local.
183183
let src_local = if let Place::Base(PlaceBase::Local(local)) = *src_place {
@@ -233,7 +233,7 @@ impl<'tcx> Action<'tcx> {
233233

234234
fn perform(self,
235235
mir: &mut Mir<'tcx>,
236-
def_use_analysis: &DefUseAnalysis<'tcx>,
236+
def_use_analysis: &DefUseAnalysis,
237237
dest_local: Local,
238238
location: Location)
239239
-> bool {

src/librustc_mir/transform/generator.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct RenameLocalVisitor {
8080
impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor {
8181
fn visit_local(&mut self,
8282
local: &mut Local,
83-
_: PlaceContext<'tcx>,
83+
_: PlaceContext,
8484
_: Location) {
8585
if *local == self.from {
8686
*local = self.to;
@@ -93,14 +93,14 @@ struct DerefArgVisitor;
9393
impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor {
9494
fn visit_local(&mut self,
9595
local: &mut Local,
96-
_: PlaceContext<'tcx>,
96+
_: PlaceContext,
9797
_: Location) {
9898
assert_ne!(*local, self_arg());
9999
}
100100

101101
fn visit_place(&mut self,
102102
place: &mut Place<'tcx>,
103-
context: PlaceContext<'tcx>,
103+
context: PlaceContext,
104104
location: Location) {
105105
if *place == Place::Base(PlaceBase::Local(self_arg())) {
106106
*place = Place::Projection(Box::new(Projection {
@@ -120,14 +120,14 @@ struct PinArgVisitor<'tcx> {
120120
impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
121121
fn visit_local(&mut self,
122122
local: &mut Local,
123-
_: PlaceContext<'tcx>,
123+
_: PlaceContext,
124124
_: Location) {
125125
assert_ne!(*local, self_arg());
126126
}
127127

128128
fn visit_place(&mut self,
129129
place: &mut Place<'tcx>,
130-
context: PlaceContext<'tcx>,
130+
context: PlaceContext,
131131
location: Location) {
132132
if *place == Place::Base(PlaceBase::Local(self_arg())) {
133133
*place = Place::Projection(Box::new(Projection {
@@ -221,14 +221,14 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> {
221221
impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> {
222222
fn visit_local(&mut self,
223223
local: &mut Local,
224-
_: PlaceContext<'tcx>,
224+
_: PlaceContext,
225225
_: Location) {
226226
assert_eq!(self.remap.get(local), None);
227227
}
228228

229229
fn visit_place(&mut self,
230230
place: &mut Place<'tcx>,
231-
context: PlaceContext<'tcx>,
231+
context: PlaceContext,
232232
location: Location) {
233233
if let Place::Base(PlaceBase::Local(l)) = *place {
234234
// Replace an Local in the remap with a generator struct access

src/librustc_mir/transform/inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'a, 'tcx> Integrator<'a, 'tcx> {
662662
impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
663663
fn visit_local(&mut self,
664664
local: &mut Local,
665-
_ctxt: PlaceContext<'tcx>,
665+
_ctxt: PlaceContext,
666666
_location: Location) {
667667
if *local == RETURN_PLACE {
668668
match self.destination {
@@ -683,7 +683,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
683683

684684
fn visit_place(&mut self,
685685
place: &mut Place<'tcx>,
686-
_ctxt: PlaceContext<'tcx>,
686+
_ctxt: PlaceContext,
687687
_location: Location) {
688688

689689
match place {

src/librustc_mir/transform/promote_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct TempCollector<'tcx> {
7777
impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
7878
fn visit_local(&mut self,
7979
&index: &Local,
80-
context: PlaceContext<'tcx>,
80+
context: PlaceContext,
8181
location: Location) {
8282
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
8383
// We're only interested in temporaries and the return place
@@ -361,7 +361,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
361361
impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
362362
fn visit_local(&mut self,
363363
local: &mut Local,
364-
_: PlaceContext<'tcx>,
364+
_: PlaceContext,
365365
_: Location) {
366366
if self.source.local_kind(*local) == LocalKind::Temp {
367367
*local = self.promote_temp(*local);

0 commit comments

Comments
 (0)