From 7859f0eac3b70fea1f129665d0b9f4c56769fa4c Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 2 Mar 2020 21:47:33 -0300 Subject: [PATCH 01/20] Make PlaceRef lifetimes of Place::as_ref be both 'tcx --- src/librustc/mir/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 668240ab42b4c..0d429d8879bac 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1864,7 +1864,7 @@ impl<'tcx> Place<'tcx> { self.as_ref().as_local() } - pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> { + pub fn as_ref(&self) -> PlaceRef<'tcx, 'tcx> { PlaceRef { local: self.local, projection: &self.projection } } } From 812e62f14609fe80c49664f8b4ee5678c126c4a3 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 2 Mar 2020 22:02:52 -0300 Subject: [PATCH 02/20] Make PlaceRef lifetimes of LocalAnalyzer::process_place be both 'tcx --- src/librustc_codegen_ssa/mir/analyze.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index 7bf222f4701b7..6214aa84b81d6 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -97,7 +97,7 @@ impl> LocalAnalyzer<'mir, 'a, 'tcx, Bx> { fn process_place( &mut self, - place_ref: &mir::PlaceRef<'_, 'tcx>, + place_ref: &mir::PlaceRef<'tcx, 'tcx>, context: PlaceContext, location: Location, ) { From 1a1dcfad6fa13f1b2b69b0e111dcad10326d36ea Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 3 Mar 2020 16:55:01 -0300 Subject: [PATCH 03/20] Make PlaceRef lifetimes of codegen_place be both 'tcx --- src/librustc_codegen_ssa/mir/operand.rs | 4 ++-- src/librustc_codegen_ssa/mir/place.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index af95450935caa..96c1351de410c 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn maybe_codegen_consume_direct( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'_, 'tcx>, + place_ref: mir::PlaceRef<'tcx, 'tcx>, ) -> Option> { debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref); @@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_consume( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'_, 'tcx>, + place_ref: mir::PlaceRef<'tcx, 'tcx>, ) -> OperandRef<'tcx, Bx::Value> { debug!("codegen_consume(place_ref={:?})", place_ref); diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index fa82daa0f7d52..0d2749d3f5feb 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_place( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'_, 'tcx>, + place_ref: mir::PlaceRef<'tcx, 'tcx>, ) -> PlaceRef<'tcx, Bx::Value> { debug!("codegen_place(place_ref={:?})", place_ref); let cx = self.cx; From 2af5e87b4b3ef9c7210e4b40ad86a14ff32932f1 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 3 Mar 2020 17:00:57 -0300 Subject: [PATCH 04/20] Make PlaceRef lifetimes of monomorphized_place_ty be both 'tcx --- src/librustc_codegen_ssa/mir/place.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 0d2749d3f5feb..3ff0c8dd2aa46 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { result } - pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> { + pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx, 'tcx>) -> Ty<'tcx> { let tcx = self.cx.tcx(); let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx); self.monomorphize(&place_ty.ty) From a20d54f00cb4b5386e1b307bc1c990eac02184da Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 3 Mar 2020 17:22:54 -0300 Subject: [PATCH 05/20] Make PlaceRef lifetimes of RootPlace be both 'tcx --- src/librustc_mir/borrow_check/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 28974dcd08bf6..4e21ba86d0996 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -841,9 +841,9 @@ enum InitializationRequiringAction { PartialAssignment, } -struct RootPlace<'d, 'tcx> { +struct RootPlace<'tcx> { place_local: Local, - place_projection: &'d [PlaceElem<'tcx>], + place_projection: &'tcx [PlaceElem<'tcx>], is_local_mutation_allowed: LocalMutationIsAllowed, } @@ -2029,7 +2029,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } /// Adds the place into the used mutable variables set - fn add_used_mut<'d>(&mut self, root_place: RootPlace<'d, 'tcx>, flow_state: &Flows<'cx, 'tcx>) { + fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'cx, 'tcx>) { match root_place { RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => { // If the local may have been initialized, and it is now currently being @@ -2063,11 +2063,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Whether this value can be written or borrowed mutably. /// Returns the root place if the place passed in is a projection. - fn is_mutable<'d>( + fn is_mutable( &self, - place: PlaceRef<'d, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, is_local_mutation_allowed: LocalMutationIsAllowed, - ) -> Result, PlaceRef<'d, 'tcx>> { + ) -> Result, PlaceRef<'tcx, 'tcx>> { match place { PlaceRef { local, projection: [] } => { let local = &self.body.local_decls[local]; From 842af362685979e011e0360984dc1ec96ba5b7e9 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 11:21:01 -0300 Subject: [PATCH 06/20] Make PlaceRef lifetimes of borrow_conflict_place be both 'tcx --- src/librustc_mir/borrow_check/mod.rs | 5 +++-- src/librustc_mir/borrow_check/places_conflict.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 4e21ba86d0996..84c9f733be058 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -86,6 +86,8 @@ crate struct Upvar { mutability: Mutability, } +const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref]; + pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { mir_borrowck, ..*providers }; } @@ -1413,7 +1415,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ) { debug!("check_for_invalidation_at_exit({:?})", borrow); let place = &borrow.borrowed_place; - let deref = [ProjectionElem::Deref]; let mut root_place = PlaceRef { local: place.local, projection: &[] }; // FIXME(nll-rfc#40): do more precise destructor tracking here. For now @@ -1427,7 +1428,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Thread-locals might be dropped after the function exits // We have to dereference the outer reference because // borrows don't conflict behind shared references. - root_place.projection = &deref; + root_place.projection = DEREF_PROJECTION; (true, true) } else { (false, self.locals_are_invalidated_at_exit) diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 984de021ca112..1f90b94cfcdc3 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -48,7 +48,7 @@ pub(super) fn borrow_conflicts_with_place<'tcx>( body: &Body<'tcx>, borrow_place: &Place<'tcx>, borrow_kind: BorrowKind, - access_place: PlaceRef<'_, 'tcx>, + access_place: PlaceRef<'tcx, 'tcx>, access: AccessDepth, bias: PlaceConflictBias, ) -> bool { @@ -73,7 +73,7 @@ fn place_components_conflict<'tcx>( body: &Body<'tcx>, borrow_place: &Place<'tcx>, borrow_kind: BorrowKind, - access_place: PlaceRef<'_, 'tcx>, + access_place: PlaceRef<'tcx, 'tcx>, access: AccessDepth, bias: PlaceConflictBias, ) -> bool { From f54e8634e1394d3436037ff54e0f87739709a916 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 13:00:08 -0300 Subject: [PATCH 07/20] Make PlaceRef lifetimes of move_error_reported be both 'tcx --- .../borrow_check/diagnostics/conflict_errors.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 11 ++++++----- src/librustc_mir/borrow_check/prefixes.rs | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index ca51d16f9f269..9d609411a54bb 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - (moved_place, used_place, span): (PlaceRef<'cx, 'tcx>, PlaceRef<'cx, 'tcx>, Span), + (moved_place, used_place, span): (PlaceRef<'cx, 'tcx>, PlaceRef<'tcx, 'tcx>, Span), mpi: MovePathIndex, ) { debug!( diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 84c9f733be058..2d73d96ec8b6a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -468,7 +468,8 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary /// when errors in the map are being re-added to the error buffer so that errors with the /// same primary span come out in a consistent order. - move_error_reported: BTreeMap, (PlaceRef<'cx, 'tcx>, DiagnosticBuilder<'cx>)>, + move_error_reported: + BTreeMap, (PlaceRef<'tcx, 'tcx>, DiagnosticBuilder<'cx>)>, /// This field keeps track of errors reported in the checking of uninitialized variables, /// so that we don't report seemingly duplicate errors. uninitialized_error_reported: FxHashSet>, @@ -1527,7 +1528,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'cx, 'tcx>, Span), + place_span: (PlaceRef<'tcx, 'tcx>, Span), flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1593,7 +1594,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'cx, 'tcx>, Span), + place_span: (PlaceRef<'tcx, 'tcx>, Span), maybe_uninits: &BitSet, from: u32, to: u32, @@ -1632,7 +1633,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'cx, 'tcx>, Span), + place_span: (PlaceRef<'tcx, 'tcx>, Span), flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1817,7 +1818,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn check_parent_of_field<'cx, 'tcx>( this: &mut MirBorrowckCtxt<'cx, 'tcx>, location: Location, - base: PlaceRef<'cx, 'tcx>, + base: PlaceRef<'tcx, 'tcx>, span: Span, flow_state: &Flows<'cx, 'tcx>, ) { diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index 31bee460fa011..b66fd42d9c024 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -29,7 +29,7 @@ pub(super) struct Prefixes<'cx, 'tcx> { body: ReadOnlyBodyAndCache<'cx, 'tcx>, tcx: TyCtxt<'tcx>, kind: PrefixSet, - next: Option>, + next: Option>, } #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -50,7 +50,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// terminating the iteration early based on `kind`. pub(super) fn prefixes( &self, - place_ref: PlaceRef<'cx, 'tcx>, + place_ref: PlaceRef<'tcx, 'tcx>, kind: PrefixSet, ) -> Prefixes<'cx, 'tcx> { Prefixes { next: Some(place_ref), kind, body: self.body, tcx: self.infcx.tcx } @@ -58,7 +58,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> { - type Item = PlaceRef<'cx, 'tcx>; + type Item = PlaceRef<'tcx, 'tcx>; fn next(&mut self) -> Option { let mut cursor = self.next?; From 6200f5c362172431279cd4feed4bd20beb7e2c7e Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 13:09:32 -0300 Subject: [PATCH 08/20] Make PlaceRef lifetimes of uninitialized_error_reported be both 'tcx --- src/librustc_mir/borrow_check/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 2d73d96ec8b6a..fb3338f998d4a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -472,7 +472,7 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { BTreeMap, (PlaceRef<'tcx, 'tcx>, DiagnosticBuilder<'cx>)>, /// This field keeps track of errors reported in the checking of uninitialized variables, /// so that we don't report seemingly duplicate errors. - uninitialized_error_reported: FxHashSet>, + uninitialized_error_reported: FxHashSet>, /// Errors to be reported buffer errors_buffer: Vec, /// This field keeps track of all the local variables that are declared mut and are mutated. From e32ee55a365712ef2cca97c0e37a8e56efecafd2 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 14:02:11 -0300 Subject: [PATCH 09/20] Make PlaceRef lifetimes of move_path_closest_to be both 'tcx --- src/librustc_mir/borrow_check/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index fb3338f998d4a..49c499fb62dbd 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1713,8 +1713,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// static variable, as we do not track those in the MoveData. fn move_path_closest_to( &mut self, - place: PlaceRef<'_, 'tcx>, - ) -> (PlaceRef<'cx, 'tcx>, MovePathIndex) { + place: PlaceRef<'tcx, 'tcx>, + ) -> (PlaceRef<'tcx, 'tcx>, MovePathIndex) { match self.move_data.rev_lookup.find(place) { LookupResult::Parent(Some(mpi)) | LookupResult::Exact(mpi) => { (self.move_data.move_paths[mpi].place.as_ref(), mpi) From 634a167e0594330fb50bf9bd742fdafeb73ed963 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 14:06:20 -0300 Subject: [PATCH 10/20] Make PlaceRef lifetimes of move_path_for_place be both 'tcx --- src/librustc_mir/borrow_check/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 49c499fb62dbd..77129a5ef9e79 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1723,7 +1723,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn move_path_for_place(&mut self, place: PlaceRef<'_, 'tcx>) -> Option { + fn move_path_for_place(&mut self, place: PlaceRef<'tcx, 'tcx>) -> Option { // If returns None, then there is no move path corresponding // to a direct owner of `place` (which means there is nothing // that borrowck tracks for its analysis). From c6f12447193d3710a38ad2e069605fe1cc2847ba Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 17:00:15 -0300 Subject: [PATCH 11/20] Make PlaceRef lifetimes of is_upvar_field_projection be both 'tcx --- .../borrow_check/diagnostics/conflict_errors.rs | 4 ++-- src/librustc_mir/borrow_check/diagnostics/mod.rs | 6 +++--- src/librustc_mir/borrow_check/mod.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 9d609411a54bb..3a74353605294 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - (moved_place, used_place, span): (PlaceRef<'cx, 'tcx>, PlaceRef<'tcx, 'tcx>, Span), + (moved_place, used_place, span): (PlaceRef<'tcx, 'tcx>, PlaceRef<'tcx, 'tcx>, Span), mpi: MovePathIndex, ) { debug!( @@ -647,7 +647,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // borrowed place and look for a access to a different field of the same union. let Place { local, projection } = second_borrowed_place; - let mut cursor = projection.as_ref(); + let mut cursor = &projection[..]; while let [proj_base @ .., elem] = cursor { cursor = proj_base; diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index cd6834a5a4d00..01c022ac2c10f 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -139,7 +139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// End-user visible description of `place` if one can be found. If the /// place is a temporary for instance, None will be returned. - pub(super) fn describe_place(&self, place_ref: PlaceRef<'cx, 'tcx>) -> Option { + pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx, 'tcx>) -> Option { self.describe_place_with_options(place_ref, IncludingDowncast(false)) } @@ -149,7 +149,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// `Downcast` and `IncludingDowncast` is true pub(super) fn describe_place_with_options( &self, - place: PlaceRef<'cx, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, including_downcast: IncludingDowncast, ) -> Option { let mut buf = String::new(); @@ -162,7 +162,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Appends end-user visible description of `place` to `buf`. fn append_place_to_string( &self, - place: PlaceRef<'cx, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, buf: &mut String, mut autoderef: bool, including_downcast: &IncludingDowncast, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 77129a5ef9e79..89a81945a27b3 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -2220,7 +2220,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// then returns the index of the field being projected. Note that this closure will always /// be `self` in the current MIR, because that is the only time we directly access the fields /// of a closure type. - pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'cx, 'tcx>) -> Option { + pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx, 'tcx>) -> Option { let mut place_projection = place_ref.projection; let mut by_ref = false; From 6f236504570de4210eeae6e883cf8ed6196e0d98 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 17:12:31 -0300 Subject: [PATCH 12/20] Make PlaceRef lifetimes of add_moved_or_invoked_closure_note be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 01c022ac2c10f..ed95c0419e9bd 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { pub(super) fn add_moved_or_invoked_closure_note( &self, location: Location, - place: PlaceRef<'cx, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, diag: &mut DiagnosticBuilder<'_>, ) { debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); From eb67eca74af8765dc4f5579655783b51f0270b49 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 17:22:28 -0300 Subject: [PATCH 13/20] Make PlaceRef lifetimes of describe_field be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index ed95c0419e9bd..2f054b8dd52d7 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -303,7 +303,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } /// End-user visible description of the `field`nth field of `base` - fn describe_field(&self, place: PlaceRef<'cx, 'tcx>, field: Field) -> String { + fn describe_field(&self, place: PlaceRef<'tcx, 'tcx>, field: Field) -> String { // FIXME Place2 Make this work iteratively match place { PlaceRef { local, projection: [] } => { From a30f55f4b2fc71acd04f5649678ca09c1523096d Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 17:47:00 -0300 Subject: [PATCH 14/20] Make PlaceRef lifetimes of borrowed_content_source be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 2 +- src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 2f054b8dd52d7..e2d59ed3c6e87 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -399,7 +399,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { pub(super) fn borrowed_content_source( &self, - deref_base: PlaceRef<'cx, 'tcx>, + deref_base: PlaceRef<'tcx, 'tcx>, ) -> BorrowedContentSource<'tcx> { let tcx = self.infcx.tcx; diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index d91f6edc9800c..aa35c407b64e6 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -23,7 +23,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { &mut self, access_place: &Place<'tcx>, span: Span, - the_place_err: PlaceRef<'cx, 'tcx>, + the_place_err: PlaceRef<'tcx, 'tcx>, error_access: AccessKind, location: Location, ) { From bd4dad4281220325dc5ae3ecca8c286ecba9b681 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:05:37 -0300 Subject: [PATCH 15/20] Make PlaceRef lifetimes of move_spans be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index e2d59ed3c6e87..2565eeae06bc5 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -694,7 +694,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Finds the spans associated to a move or copy of move_place at location. pub(super) fn move_spans( &self, - moved_place: PlaceRef<'cx, 'tcx>, // Could also be an upvar. + moved_place: PlaceRef<'tcx, 'tcx>, // Could also be an upvar. location: Location, ) -> UseSpans { use self::UseSpans::*; From 46d85e519bcd2b64ca0b069055e880b425fb3e74 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:07:33 -0300 Subject: [PATCH 16/20] Make PlaceRef lifetimes of closure_span be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 2565eeae06bc5..4b1c0b05817de 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -782,7 +782,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn closure_span( &self, def_id: DefId, - target_place: PlaceRef<'cx, 'tcx>, + target_place: PlaceRef<'tcx, 'tcx>, places: &Vec>, ) -> Option<(Span, Option, Span)> { debug!( From a32afa33c8a8ad58607bafbfb9399b2c51495e61 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:10:01 -0300 Subject: [PATCH 17/20] Make PlaceRef lifetimes of classify_drop_access_kind be both 'tcx --- src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 3a74353605294..99cbc76efab88 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -1521,7 +1521,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.buffer(&mut self.errors_buffer); } - fn classify_drop_access_kind(&self, place: PlaceRef<'cx, 'tcx>) -> StorageDeadOrDrop<'tcx> { + fn classify_drop_access_kind(&self, place: PlaceRef<'tcx, 'tcx>) -> StorageDeadOrDrop<'tcx> { let tcx = self.infcx.tcx; match place.projection { [] => StorageDeadOrDrop::LocalStorageDead, From a5d1e189a12433d61ded6da47df76929cf8e94c1 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:13:47 -0300 Subject: [PATCH 18/20] Make PlaceRef lifetimes of is_prefix_of be both 'tcx --- src/librustc_mir/borrow_check/prefixes.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index b66fd42d9c024..25356cd17ef18 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -13,12 +13,12 @@ use rustc::mir::{Place, PlaceRef, ProjectionElem, ReadOnlyBodyAndCache}; use rustc::ty::{self, TyCtxt}; use rustc_hir as hir; -pub trait IsPrefixOf<'cx, 'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'cx, 'tcx>) -> bool; +pub trait IsPrefixOf<'tcx> { + fn is_prefix_of(&self, other: PlaceRef<'tcx, 'tcx>) -> bool; } -impl<'cx, 'tcx> IsPrefixOf<'cx, 'tcx> for PlaceRef<'cx, 'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'cx, 'tcx>) -> bool { +impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx, 'tcx> { + fn is_prefix_of(&self, other: PlaceRef<'tcx, 'tcx>) -> bool { self.local == other.local && self.projection.len() <= other.projection.len() && self.projection == &other.projection[..self.projection.len()] From 2cb2559c18c2d494710ab67324cdc73c4be7a46f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:18:15 -0300 Subject: [PATCH 19/20] Make PlaceRef lifetimes of in_projection be both 'tcx --- src/librustc_mir/dataflow/move_paths/builder.rs | 2 +- src/librustc_mir/transform/check_consts/qualifs.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 57aa5de7f7a31..fb7ae102a0f18 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -483,7 +483,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { self.builder.data.loc_map[self.loc].push(move_out); } - fn gather_init(&mut self, place: PlaceRef<'cx, 'tcx>, kind: InitKind) { + fn gather_init(&mut self, place: PlaceRef<'tcx, 'tcx>, kind: InitKind) { debug!("gather_init({:?}, {:?})", self.loc, place); let mut place = place; diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 215496e4d03cb..275b6e4d508f0 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -35,7 +35,7 @@ pub trait Qualif { fn in_projection_structurally( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'_, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, ) -> bool { if let [proj_base @ .., elem] = place.projection { let base_qualif = Self::in_place( @@ -67,7 +67,7 @@ pub trait Qualif { fn in_projection( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'_, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, ) -> bool { Self::in_projection_structurally(cx, per_local, place) } @@ -75,7 +75,7 @@ pub trait Qualif { fn in_place( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'_, 'tcx>, + place: PlaceRef<'tcx, 'tcx>, ) -> bool { match place { PlaceRef { local, projection: [] } => per_local(local), From b11cd0b587cc2a663ef358089a2d1cf709170371 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 4 Mar 2020 18:25:03 -0300 Subject: [PATCH 20/20] PlaceRef<'a, 'tcx> -> PlaceRef<'tcx> --- src/librustc/mir/mod.rs | 8 +++--- src/librustc_codegen_ssa/mir/analyze.rs | 2 +- src/librustc_codegen_ssa/mir/operand.rs | 4 +-- src/librustc_codegen_ssa/mir/place.rs | 4 +-- .../diagnostics/conflict_errors.rs | 4 +-- .../borrow_check/diagnostics/mod.rs | 16 ++++++------ .../diagnostics/mutability_errors.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 26 ++++++++----------- .../borrow_check/places_conflict.rs | 4 +-- src/librustc_mir/borrow_check/prefixes.rs | 12 ++++----- .../dataflow/move_paths/builder.rs | 2 +- src/librustc_mir/dataflow/move_paths/mod.rs | 2 +- src/librustc_mir/transform/add_retag.rs | 2 +- .../transform/check_consts/qualifs.rs | 6 ++--- src/librustc_mir/transform/promote_consts.rs | 2 +- 15 files changed, 46 insertions(+), 50 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 0d429d8879bac..ca97366f5146a 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1827,9 +1827,9 @@ rustc_index::newtype_index! { } #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct PlaceRef<'a, 'tcx> { +pub struct PlaceRef<'tcx> { pub local: Local, - pub projection: &'a [PlaceElem<'tcx>], + pub projection: &'tcx [PlaceElem<'tcx>], } impl<'tcx> Place<'tcx> { @@ -1864,7 +1864,7 @@ impl<'tcx> Place<'tcx> { self.as_ref().as_local() } - pub fn as_ref(&self) -> PlaceRef<'tcx, 'tcx> { + pub fn as_ref(&self) -> PlaceRef<'tcx> { PlaceRef { local: self.local, projection: &self.projection } } } @@ -1875,7 +1875,7 @@ impl From for Place<'_> { } } -impl<'a, 'tcx> PlaceRef<'a, 'tcx> { +impl<'tcx> PlaceRef<'tcx> { /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or /// a single deref of a local. // diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index 6214aa84b81d6..2f7e70901f0f3 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -97,7 +97,7 @@ impl> LocalAnalyzer<'mir, 'a, 'tcx, Bx> { fn process_place( &mut self, - place_ref: &mir::PlaceRef<'tcx, 'tcx>, + place_ref: &mir::PlaceRef<'tcx>, context: PlaceContext, location: Location, ) { diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 96c1351de410c..1e1fede2588df 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -364,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn maybe_codegen_consume_direct( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'tcx, 'tcx>, + place_ref: mir::PlaceRef<'tcx>, ) -> Option> { debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref); @@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_consume( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'tcx, 'tcx>, + place_ref: mir::PlaceRef<'tcx>, ) -> OperandRef<'tcx, Bx::Value> { debug!("codegen_consume(place_ref={:?})", place_ref); diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 3ff0c8dd2aa46..2eba88c6b5f31 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_place( &mut self, bx: &mut Bx, - place_ref: mir::PlaceRef<'tcx, 'tcx>, + place_ref: mir::PlaceRef<'tcx>, ) -> PlaceRef<'tcx, Bx::Value> { debug!("codegen_place(place_ref={:?})", place_ref); let cx = self.cx; @@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { result } - pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx, 'tcx>) -> Ty<'tcx> { + pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> { let tcx = self.cx.tcx(); let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx); self.monomorphize(&place_ty.ty) diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 99cbc76efab88..6dc5d62babda6 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - (moved_place, used_place, span): (PlaceRef<'tcx, 'tcx>, PlaceRef<'tcx, 'tcx>, Span), + (moved_place, used_place, span): (PlaceRef<'tcx>, PlaceRef<'tcx>, Span), mpi: MovePathIndex, ) { debug!( @@ -1521,7 +1521,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.buffer(&mut self.errors_buffer); } - fn classify_drop_access_kind(&self, place: PlaceRef<'tcx, 'tcx>) -> StorageDeadOrDrop<'tcx> { + fn classify_drop_access_kind(&self, place: PlaceRef<'tcx>) -> StorageDeadOrDrop<'tcx> { let tcx = self.infcx.tcx; match place.projection { [] => StorageDeadOrDrop::LocalStorageDead, diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 4b1c0b05817de..912b5f11f1a04 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -51,7 +51,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { pub(super) fn add_moved_or_invoked_closure_note( &self, location: Location, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, diag: &mut DiagnosticBuilder<'_>, ) { debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); @@ -139,7 +139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// End-user visible description of `place` if one can be found. If the /// place is a temporary for instance, None will be returned. - pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx, 'tcx>) -> Option { + pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option { self.describe_place_with_options(place_ref, IncludingDowncast(false)) } @@ -149,7 +149,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// `Downcast` and `IncludingDowncast` is true pub(super) fn describe_place_with_options( &self, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, including_downcast: IncludingDowncast, ) -> Option { let mut buf = String::new(); @@ -162,7 +162,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Appends end-user visible description of `place` to `buf`. fn append_place_to_string( &self, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, buf: &mut String, mut autoderef: bool, including_downcast: &IncludingDowncast, @@ -303,7 +303,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } /// End-user visible description of the `field`nth field of `base` - fn describe_field(&self, place: PlaceRef<'tcx, 'tcx>, field: Field) -> String { + fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String { // FIXME Place2 Make this work iteratively match place { PlaceRef { local, projection: [] } => { @@ -399,7 +399,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { pub(super) fn borrowed_content_source( &self, - deref_base: PlaceRef<'tcx, 'tcx>, + deref_base: PlaceRef<'tcx>, ) -> BorrowedContentSource<'tcx> { let tcx = self.infcx.tcx; @@ -694,7 +694,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Finds the spans associated to a move or copy of move_place at location. pub(super) fn move_spans( &self, - moved_place: PlaceRef<'tcx, 'tcx>, // Could also be an upvar. + moved_place: PlaceRef<'tcx>, // Could also be an upvar. location: Location, ) -> UseSpans { use self::UseSpans::*; @@ -782,7 +782,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn closure_span( &self, def_id: DefId, - target_place: PlaceRef<'tcx, 'tcx>, + target_place: PlaceRef<'tcx>, places: &Vec>, ) -> Option<(Span, Option, Span)> { debug!( diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index aa35c407b64e6..1a13ef8958576 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -23,7 +23,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { &mut self, access_place: &Place<'tcx>, span: Span, - the_place_err: PlaceRef<'tcx, 'tcx>, + the_place_err: PlaceRef<'tcx>, error_access: AccessKind, location: Location, ) { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 89a81945a27b3..4e84a4169890e 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -468,11 +468,10 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary /// when errors in the map are being re-added to the error buffer so that errors with the /// same primary span come out in a consistent order. - move_error_reported: - BTreeMap, (PlaceRef<'tcx, 'tcx>, DiagnosticBuilder<'cx>)>, + move_error_reported: BTreeMap, (PlaceRef<'tcx>, DiagnosticBuilder<'cx>)>, /// This field keeps track of errors reported in the checking of uninitialized variables, /// so that we don't report seemingly duplicate errors. - uninitialized_error_reported: FxHashSet>, + uninitialized_error_reported: FxHashSet>, /// Errors to be reported buffer errors_buffer: Vec, /// This field keeps track of all the local variables that are declared mut and are mutated. @@ -1528,7 +1527,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'tcx, 'tcx>, Span), + place_span: (PlaceRef<'tcx>, Span), flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1594,7 +1593,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'tcx, 'tcx>, Span), + place_span: (PlaceRef<'tcx>, Span), maybe_uninits: &BitSet, from: u32, to: u32, @@ -1633,7 +1632,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, desired_action: InitializationRequiringAction, - place_span: (PlaceRef<'tcx, 'tcx>, Span), + place_span: (PlaceRef<'tcx>, Span), flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1711,10 +1710,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// An Err result includes a tag indicated why the search failed. /// Currently this can only occur if the place is built off of a /// static variable, as we do not track those in the MoveData. - fn move_path_closest_to( - &mut self, - place: PlaceRef<'tcx, 'tcx>, - ) -> (PlaceRef<'tcx, 'tcx>, MovePathIndex) { + fn move_path_closest_to(&mut self, place: PlaceRef<'tcx>) -> (PlaceRef<'tcx>, MovePathIndex) { match self.move_data.rev_lookup.find(place) { LookupResult::Parent(Some(mpi)) | LookupResult::Exact(mpi) => { (self.move_data.move_paths[mpi].place.as_ref(), mpi) @@ -1723,7 +1719,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn move_path_for_place(&mut self, place: PlaceRef<'tcx, 'tcx>) -> Option { + fn move_path_for_place(&mut self, place: PlaceRef<'tcx>) -> Option { // If returns None, then there is no move path corresponding // to a direct owner of `place` (which means there is nothing // that borrowck tracks for its analysis). @@ -1818,7 +1814,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn check_parent_of_field<'cx, 'tcx>( this: &mut MirBorrowckCtxt<'cx, 'tcx>, location: Location, - base: PlaceRef<'tcx, 'tcx>, + base: PlaceRef<'tcx>, span: Span, flow_state: &Flows<'cx, 'tcx>, ) { @@ -2067,9 +2063,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Returns the root place if the place passed in is a projection. fn is_mutable( &self, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, is_local_mutation_allowed: LocalMutationIsAllowed, - ) -> Result, PlaceRef<'tcx, 'tcx>> { + ) -> Result, PlaceRef<'tcx>> { match place { PlaceRef { local, projection: [] } => { let local = &self.body.local_decls[local]; @@ -2220,7 +2216,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// then returns the index of the field being projected. Note that this closure will always /// be `self` in the current MIR, because that is the only time we directly access the fields /// of a closure type. - pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx, 'tcx>) -> Option { + pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option { let mut place_projection = place_ref.projection; let mut by_ref = false; diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 1f90b94cfcdc3..767ffa50fedb4 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -48,7 +48,7 @@ pub(super) fn borrow_conflicts_with_place<'tcx>( body: &Body<'tcx>, borrow_place: &Place<'tcx>, borrow_kind: BorrowKind, - access_place: PlaceRef<'tcx, 'tcx>, + access_place: PlaceRef<'tcx>, access: AccessDepth, bias: PlaceConflictBias, ) -> bool { @@ -73,7 +73,7 @@ fn place_components_conflict<'tcx>( body: &Body<'tcx>, borrow_place: &Place<'tcx>, borrow_kind: BorrowKind, - access_place: PlaceRef<'tcx, 'tcx>, + access_place: PlaceRef<'tcx>, access: AccessDepth, bias: PlaceConflictBias, ) -> bool { diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index 25356cd17ef18..c64e8c363af54 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -14,11 +14,11 @@ use rustc::ty::{self, TyCtxt}; use rustc_hir as hir; pub trait IsPrefixOf<'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx, 'tcx>) -> bool; + fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool; } -impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx, 'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx, 'tcx>) -> bool { +impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> { + fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool { self.local == other.local && self.projection.len() <= other.projection.len() && self.projection == &other.projection[..self.projection.len()] @@ -29,7 +29,7 @@ pub(super) struct Prefixes<'cx, 'tcx> { body: ReadOnlyBodyAndCache<'cx, 'tcx>, tcx: TyCtxt<'tcx>, kind: PrefixSet, - next: Option>, + next: Option>, } #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -50,7 +50,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// terminating the iteration early based on `kind`. pub(super) fn prefixes( &self, - place_ref: PlaceRef<'tcx, 'tcx>, + place_ref: PlaceRef<'tcx>, kind: PrefixSet, ) -> Prefixes<'cx, 'tcx> { Prefixes { next: Some(place_ref), kind, body: self.body, tcx: self.infcx.tcx } @@ -58,7 +58,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> { - type Item = PlaceRef<'tcx, 'tcx>; + type Item = PlaceRef<'tcx>; fn next(&mut self) -> Option { let mut cursor = self.next?; diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index fb7ae102a0f18..0272e0c3a872a 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -483,7 +483,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { self.builder.data.loc_map[self.loc].push(move_out); } - fn gather_init(&mut self, place: PlaceRef<'tcx, 'tcx>, kind: InitKind) { + fn gather_init(&mut self, place: PlaceRef<'tcx>, kind: InitKind) { debug!("gather_init({:?}, {:?})", self.loc, place); let mut place = place; diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index 6f6ba7dc27128..593952bfa7c80 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -312,7 +312,7 @@ impl MovePathLookup { // alternative will *not* create a MovePath on the fly for an // unknown place, but will rather return the nearest available // parent. - pub fn find(&self, place: PlaceRef<'_, '_>) -> LookupResult { + pub fn find(&self, place: PlaceRef<'_>) -> LookupResult { let mut result = self.locals[place.local]; for elem in place.projection.iter() { diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index a5b467c1e101f..a12d6e02a80b1 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -14,7 +14,7 @@ pub struct AddRetag; /// after the assignment, we can be sure to obtain the same place value. /// (Concurrent accesses by other threads are no problem as these are anyway non-atomic /// copies. Data races are UB.) -fn is_stable(place: PlaceRef<'_, '_>) -> bool { +fn is_stable(place: PlaceRef<'_>) -> bool { place.projection.iter().all(|elem| { match elem { // Which place this evaluates to can change with any memory write, diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 275b6e4d508f0..baff8383c20a4 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -35,7 +35,7 @@ pub trait Qualif { fn in_projection_structurally( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, ) -> bool { if let [proj_base @ .., elem] = place.projection { let base_qualif = Self::in_place( @@ -67,7 +67,7 @@ pub trait Qualif { fn in_projection( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, ) -> bool { Self::in_projection_structurally(cx, per_local, place) } @@ -75,7 +75,7 @@ pub trait Qualif { fn in_place( cx: &ConstCx<'_, 'tcx>, per_local: &mut impl FnMut(Local) -> bool, - place: PlaceRef<'tcx, 'tcx>, + place: PlaceRef<'tcx>, ) -> bool { match place { PlaceRef { local, projection: [] } => per_local(local), diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 286740f99dde6..33f4e126f1efd 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -474,7 +474,7 @@ impl<'tcx> Validator<'_, 'tcx> { } } - fn validate_place(&self, place: PlaceRef<'_, 'tcx>) -> Result<(), Unpromotable> { + fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> { match place { PlaceRef { local, projection: [] } => self.validate_local(local), PlaceRef { local: _, projection: [proj_base @ .., elem] } => {