Skip to content

Commit b059d02

Browse files
authored
Rollup merge of rust-lang#69714 - spastorino:place-ref-lifetime, r=oli-obk
Make PlaceRef take just one lifetime r? @eddyb
2 parents cc35ba6 + b11cd0b commit b059d02

File tree

15 files changed

+55
-57
lines changed

15 files changed

+55
-57
lines changed

src/librustc/mir/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1827,9 +1827,9 @@ rustc_index::newtype_index! {
18271827
}
18281828

18291829
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1830-
pub struct PlaceRef<'a, 'tcx> {
1830+
pub struct PlaceRef<'tcx> {
18311831
pub local: Local,
1832-
pub projection: &'a [PlaceElem<'tcx>],
1832+
pub projection: &'tcx [PlaceElem<'tcx>],
18331833
}
18341834

18351835
impl<'tcx> Place<'tcx> {
@@ -1864,7 +1864,7 @@ impl<'tcx> Place<'tcx> {
18641864
self.as_ref().as_local()
18651865
}
18661866

1867-
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
1867+
pub fn as_ref(&self) -> PlaceRef<'tcx> {
18681868
PlaceRef { local: self.local, projection: &self.projection }
18691869
}
18701870
}
@@ -1875,7 +1875,7 @@ impl From<Local> for Place<'_> {
18751875
}
18761876
}
18771877

1878-
impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
1878+
impl<'tcx> PlaceRef<'tcx> {
18791879
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
18801880
/// a single deref of a local.
18811881
//

src/librustc_codegen_ssa/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
9797

9898
fn process_place(
9999
&mut self,
100-
place_ref: &mir::PlaceRef<'_, 'tcx>,
100+
place_ref: &mir::PlaceRef<'tcx>,
101101
context: PlaceContext,
102102
location: Location,
103103
) {

src/librustc_codegen_ssa/mir/operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
364364
fn maybe_codegen_consume_direct(
365365
&mut self,
366366
bx: &mut Bx,
367-
place_ref: mir::PlaceRef<'_, 'tcx>,
367+
place_ref: mir::PlaceRef<'tcx>,
368368
) -> Option<OperandRef<'tcx, Bx::Value>> {
369369
debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref);
370370

@@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
408408
pub fn codegen_consume(
409409
&mut self,
410410
bx: &mut Bx,
411-
place_ref: mir::PlaceRef<'_, 'tcx>,
411+
place_ref: mir::PlaceRef<'tcx>,
412412
) -> OperandRef<'tcx, Bx::Value> {
413413
debug!("codegen_consume(place_ref={:?})", place_ref);
414414

src/librustc_codegen_ssa/mir/place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
408408
pub fn codegen_place(
409409
&mut self,
410410
bx: &mut Bx,
411-
place_ref: mir::PlaceRef<'_, 'tcx>,
411+
place_ref: mir::PlaceRef<'tcx>,
412412
) -> PlaceRef<'tcx, Bx::Value> {
413413
debug!("codegen_place(place_ref={:?})", place_ref);
414414
let cx = self.cx;
@@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
497497
result
498498
}
499499

500-
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
500+
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
501501
let tcx = self.cx.tcx();
502502
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
503503
self.monomorphize(&place_ty.ty)

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
5151
&mut self,
5252
location: Location,
5353
desired_action: InitializationRequiringAction,
54-
(moved_place, used_place, span): (PlaceRef<'cx, 'tcx>, PlaceRef<'cx, 'tcx>, Span),
54+
(moved_place, used_place, span): (PlaceRef<'tcx>, PlaceRef<'tcx>, Span),
5555
mpi: MovePathIndex,
5656
) {
5757
debug!(
@@ -647,7 +647,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
647647
// borrowed place and look for a access to a different field of the same union.
648648
let Place { local, projection } = second_borrowed_place;
649649

650-
let mut cursor = projection.as_ref();
650+
let mut cursor = &projection[..];
651651
while let [proj_base @ .., elem] = cursor {
652652
cursor = proj_base;
653653

@@ -1521,7 +1521,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15211521
err.buffer(&mut self.errors_buffer);
15221522
}
15231523

1524-
fn classify_drop_access_kind(&self, place: PlaceRef<'cx, 'tcx>) -> StorageDeadOrDrop<'tcx> {
1524+
fn classify_drop_access_kind(&self, place: PlaceRef<'tcx>) -> StorageDeadOrDrop<'tcx> {
15251525
let tcx = self.infcx.tcx;
15261526
match place.projection {
15271527
[] => StorageDeadOrDrop::LocalStorageDead,

src/librustc_mir/borrow_check/diagnostics/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
5151
pub(super) fn add_moved_or_invoked_closure_note(
5252
&self,
5353
location: Location,
54-
place: PlaceRef<'cx, 'tcx>,
54+
place: PlaceRef<'tcx>,
5555
diag: &mut DiagnosticBuilder<'_>,
5656
) {
5757
debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place);
@@ -139,7 +139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
139139

140140
/// End-user visible description of `place` if one can be found. If the
141141
/// place is a temporary for instance, None will be returned.
142-
pub(super) fn describe_place(&self, place_ref: PlaceRef<'cx, 'tcx>) -> Option<String> {
142+
pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> {
143143
self.describe_place_with_options(place_ref, IncludingDowncast(false))
144144
}
145145

@@ -149,7 +149,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
149149
/// `Downcast` and `IncludingDowncast` is true
150150
pub(super) fn describe_place_with_options(
151151
&self,
152-
place: PlaceRef<'cx, 'tcx>,
152+
place: PlaceRef<'tcx>,
153153
including_downcast: IncludingDowncast,
154154
) -> Option<String> {
155155
let mut buf = String::new();
@@ -162,7 +162,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
162162
/// Appends end-user visible description of `place` to `buf`.
163163
fn append_place_to_string(
164164
&self,
165-
place: PlaceRef<'cx, 'tcx>,
165+
place: PlaceRef<'tcx>,
166166
buf: &mut String,
167167
mut autoderef: bool,
168168
including_downcast: &IncludingDowncast,
@@ -303,7 +303,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
303303
}
304304

305305
/// End-user visible description of the `field`nth field of `base`
306-
fn describe_field(&self, place: PlaceRef<'cx, 'tcx>, field: Field) -> String {
306+
fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String {
307307
// FIXME Place2 Make this work iteratively
308308
match place {
309309
PlaceRef { local, projection: [] } => {
@@ -399,7 +399,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
399399

400400
pub(super) fn borrowed_content_source(
401401
&self,
402-
deref_base: PlaceRef<'cx, 'tcx>,
402+
deref_base: PlaceRef<'tcx>,
403403
) -> BorrowedContentSource<'tcx> {
404404
let tcx = self.infcx.tcx;
405405

@@ -694,7 +694,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
694694
/// Finds the spans associated to a move or copy of move_place at location.
695695
pub(super) fn move_spans(
696696
&self,
697-
moved_place: PlaceRef<'cx, 'tcx>, // Could also be an upvar.
697+
moved_place: PlaceRef<'tcx>, // Could also be an upvar.
698698
location: Location,
699699
) -> UseSpans {
700700
use self::UseSpans::*;
@@ -782,7 +782,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
782782
fn closure_span(
783783
&self,
784784
def_id: DefId,
785-
target_place: PlaceRef<'cx, 'tcx>,
785+
target_place: PlaceRef<'tcx>,
786786
places: &Vec<Operand<'tcx>>,
787787
) -> Option<(Span, Option<GeneratorKind>, Span)> {
788788
debug!(

src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
2323
&mut self,
2424
access_place: &Place<'tcx>,
2525
span: Span,
26-
the_place_err: PlaceRef<'cx, 'tcx>,
26+
the_place_err: PlaceRef<'tcx>,
2727
error_access: AccessKind,
2828
location: Location,
2929
) {

src/librustc_mir/borrow_check/mod.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ crate struct Upvar {
8686
mutability: Mutability,
8787
}
8888

89+
const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
90+
8991
pub fn provide(providers: &mut Providers<'_>) {
9092
*providers = Providers { mir_borrowck, ..*providers };
9193
}
@@ -466,10 +468,10 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
466468
/// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
467469
/// when errors in the map are being re-added to the error buffer so that errors with the
468470
/// same primary span come out in a consistent order.
469-
move_error_reported: BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'cx, 'tcx>, DiagnosticBuilder<'cx>)>,
471+
move_error_reported: BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'cx>)>,
470472
/// This field keeps track of errors reported in the checking of uninitialized variables,
471473
/// so that we don't report seemingly duplicate errors.
472-
uninitialized_error_reported: FxHashSet<PlaceRef<'cx, 'tcx>>,
474+
uninitialized_error_reported: FxHashSet<PlaceRef<'tcx>>,
473475
/// Errors to be reported buffer
474476
errors_buffer: Vec<Diagnostic>,
475477
/// This field keeps track of all the local variables that are declared mut and are mutated.
@@ -841,9 +843,9 @@ enum InitializationRequiringAction {
841843
PartialAssignment,
842844
}
843845

844-
struct RootPlace<'d, 'tcx> {
846+
struct RootPlace<'tcx> {
845847
place_local: Local,
846-
place_projection: &'d [PlaceElem<'tcx>],
848+
place_projection: &'tcx [PlaceElem<'tcx>],
847849
is_local_mutation_allowed: LocalMutationIsAllowed,
848850
}
849851

@@ -1413,7 +1415,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14131415
) {
14141416
debug!("check_for_invalidation_at_exit({:?})", borrow);
14151417
let place = &borrow.borrowed_place;
1416-
let deref = [ProjectionElem::Deref];
14171418
let mut root_place = PlaceRef { local: place.local, projection: &[] };
14181419

14191420
// FIXME(nll-rfc#40): do more precise destructor tracking here. For now
@@ -1427,7 +1428,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14271428
// Thread-locals might be dropped after the function exits
14281429
// We have to dereference the outer reference because
14291430
// borrows don't conflict behind shared references.
1430-
root_place.projection = &deref;
1431+
root_place.projection = DEREF_PROJECTION;
14311432
(true, true)
14321433
} else {
14331434
(false, self.locals_are_invalidated_at_exit)
@@ -1526,7 +1527,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15261527
&mut self,
15271528
location: Location,
15281529
desired_action: InitializationRequiringAction,
1529-
place_span: (PlaceRef<'cx, 'tcx>, Span),
1530+
place_span: (PlaceRef<'tcx>, Span),
15301531
flow_state: &Flows<'cx, 'tcx>,
15311532
) {
15321533
let maybe_uninits = &flow_state.uninits;
@@ -1592,7 +1593,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15921593
&mut self,
15931594
location: Location,
15941595
desired_action: InitializationRequiringAction,
1595-
place_span: (PlaceRef<'cx, 'tcx>, Span),
1596+
place_span: (PlaceRef<'tcx>, Span),
15961597
maybe_uninits: &BitSet<MovePathIndex>,
15971598
from: u32,
15981599
to: u32,
@@ -1631,7 +1632,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16311632
&mut self,
16321633
location: Location,
16331634
desired_action: InitializationRequiringAction,
1634-
place_span: (PlaceRef<'cx, 'tcx>, Span),
1635+
place_span: (PlaceRef<'tcx>, Span),
16351636
flow_state: &Flows<'cx, 'tcx>,
16361637
) {
16371638
let maybe_uninits = &flow_state.uninits;
@@ -1709,10 +1710,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17091710
/// An Err result includes a tag indicated why the search failed.
17101711
/// Currently this can only occur if the place is built off of a
17111712
/// static variable, as we do not track those in the MoveData.
1712-
fn move_path_closest_to(
1713-
&mut self,
1714-
place: PlaceRef<'_, 'tcx>,
1715-
) -> (PlaceRef<'cx, 'tcx>, MovePathIndex) {
1713+
fn move_path_closest_to(&mut self, place: PlaceRef<'tcx>) -> (PlaceRef<'tcx>, MovePathIndex) {
17161714
match self.move_data.rev_lookup.find(place) {
17171715
LookupResult::Parent(Some(mpi)) | LookupResult::Exact(mpi) => {
17181716
(self.move_data.move_paths[mpi].place.as_ref(), mpi)
@@ -1721,7 +1719,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17211719
}
17221720
}
17231721

1724-
fn move_path_for_place(&mut self, place: PlaceRef<'_, 'tcx>) -> Option<MovePathIndex> {
1722+
fn move_path_for_place(&mut self, place: PlaceRef<'tcx>) -> Option<MovePathIndex> {
17251723
// If returns None, then there is no move path corresponding
17261724
// to a direct owner of `place` (which means there is nothing
17271725
// that borrowck tracks for its analysis).
@@ -1816,7 +1814,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
18161814
fn check_parent_of_field<'cx, 'tcx>(
18171815
this: &mut MirBorrowckCtxt<'cx, 'tcx>,
18181816
location: Location,
1819-
base: PlaceRef<'cx, 'tcx>,
1817+
base: PlaceRef<'tcx>,
18201818
span: Span,
18211819
flow_state: &Flows<'cx, 'tcx>,
18221820
) {
@@ -2029,7 +2027,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20292027
}
20302028

20312029
/// Adds the place into the used mutable variables set
2032-
fn add_used_mut<'d>(&mut self, root_place: RootPlace<'d, 'tcx>, flow_state: &Flows<'cx, 'tcx>) {
2030+
fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'cx, 'tcx>) {
20332031
match root_place {
20342032
RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => {
20352033
// If the local may have been initialized, and it is now currently being
@@ -2063,11 +2061,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20632061

20642062
/// Whether this value can be written or borrowed mutably.
20652063
/// Returns the root place if the place passed in is a projection.
2066-
fn is_mutable<'d>(
2064+
fn is_mutable(
20672065
&self,
2068-
place: PlaceRef<'d, 'tcx>,
2066+
place: PlaceRef<'tcx>,
20692067
is_local_mutation_allowed: LocalMutationIsAllowed,
2070-
) -> Result<RootPlace<'d, 'tcx>, PlaceRef<'d, 'tcx>> {
2068+
) -> Result<RootPlace<'tcx>, PlaceRef<'tcx>> {
20712069
match place {
20722070
PlaceRef { local, projection: [] } => {
20732071
let local = &self.body.local_decls[local];
@@ -2218,7 +2216,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
22182216
/// then returns the index of the field being projected. Note that this closure will always
22192217
/// be `self` in the current MIR, because that is the only time we directly access the fields
22202218
/// of a closure type.
2221-
pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'cx, 'tcx>) -> Option<Field> {
2219+
pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option<Field> {
22222220
let mut place_projection = place_ref.projection;
22232221
let mut by_ref = false;
22242222

src/librustc_mir/borrow_check/places_conflict.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(super) fn borrow_conflicts_with_place<'tcx>(
4848
body: &Body<'tcx>,
4949
borrow_place: &Place<'tcx>,
5050
borrow_kind: BorrowKind,
51-
access_place: PlaceRef<'_, 'tcx>,
51+
access_place: PlaceRef<'tcx>,
5252
access: AccessDepth,
5353
bias: PlaceConflictBias,
5454
) -> bool {
@@ -73,7 +73,7 @@ fn place_components_conflict<'tcx>(
7373
body: &Body<'tcx>,
7474
borrow_place: &Place<'tcx>,
7575
borrow_kind: BorrowKind,
76-
access_place: PlaceRef<'_, 'tcx>,
76+
access_place: PlaceRef<'tcx>,
7777
access: AccessDepth,
7878
bias: PlaceConflictBias,
7979
) -> bool {

src/librustc_mir/borrow_check/prefixes.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use rustc::mir::{Place, PlaceRef, ProjectionElem, ReadOnlyBodyAndCache};
1313
use rustc::ty::{self, TyCtxt};
1414
use rustc_hir as hir;
1515

16-
pub trait IsPrefixOf<'cx, 'tcx> {
17-
fn is_prefix_of(&self, other: PlaceRef<'cx, 'tcx>) -> bool;
16+
pub trait IsPrefixOf<'tcx> {
17+
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
1818
}
1919

20-
impl<'cx, 'tcx> IsPrefixOf<'cx, 'tcx> for PlaceRef<'cx, 'tcx> {
21-
fn is_prefix_of(&self, other: PlaceRef<'cx, 'tcx>) -> bool {
20+
impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> {
21+
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
2222
self.local == other.local
2323
&& self.projection.len() <= other.projection.len()
2424
&& self.projection == &other.projection[..self.projection.len()]
@@ -29,7 +29,7 @@ pub(super) struct Prefixes<'cx, 'tcx> {
2929
body: ReadOnlyBodyAndCache<'cx, 'tcx>,
3030
tcx: TyCtxt<'tcx>,
3131
kind: PrefixSet,
32-
next: Option<PlaceRef<'cx, 'tcx>>,
32+
next: Option<PlaceRef<'tcx>>,
3333
}
3434

3535
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -50,15 +50,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
5050
/// terminating the iteration early based on `kind`.
5151
pub(super) fn prefixes(
5252
&self,
53-
place_ref: PlaceRef<'cx, 'tcx>,
53+
place_ref: PlaceRef<'tcx>,
5454
kind: PrefixSet,
5555
) -> Prefixes<'cx, 'tcx> {
5656
Prefixes { next: Some(place_ref), kind, body: self.body, tcx: self.infcx.tcx }
5757
}
5858
}
5959

6060
impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
61-
type Item = PlaceRef<'cx, 'tcx>;
61+
type Item = PlaceRef<'tcx>;
6262
fn next(&mut self) -> Option<Self::Item> {
6363
let mut cursor = self.next?;
6464

src/librustc_mir/dataflow/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
483483
self.builder.data.loc_map[self.loc].push(move_out);
484484
}
485485

486-
fn gather_init(&mut self, place: PlaceRef<'cx, 'tcx>, kind: InitKind) {
486+
fn gather_init(&mut self, place: PlaceRef<'tcx>, kind: InitKind) {
487487
debug!("gather_init({:?}, {:?})", self.loc, place);
488488

489489
let mut place = place;

0 commit comments

Comments
 (0)