@@ -86,6 +86,8 @@ crate struct Upvar {
86
86
mutability : Mutability ,
87
87
}
88
88
89
+ const DEREF_PROJECTION : & [ PlaceElem < ' _ > ; 1 ] = & [ ProjectionElem :: Deref ] ;
90
+
89
91
pub fn provide ( providers : & mut Providers < ' _ > ) {
90
92
* providers = Providers { mir_borrowck, ..* providers } ;
91
93
}
@@ -466,10 +468,10 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
466
468
/// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
467
469
/// when errors in the map are being re-added to the error buffer so that errors with the
468
470
/// 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 > ) > ,
470
472
/// This field keeps track of errors reported in the checking of uninitialized variables,
471
473
/// so that we don't report seemingly duplicate errors.
472
- uninitialized_error_reported : FxHashSet < PlaceRef < ' cx , ' tcx > > ,
474
+ uninitialized_error_reported : FxHashSet < PlaceRef < ' tcx > > ,
473
475
/// Errors to be reported buffer
474
476
errors_buffer : Vec < Diagnostic > ,
475
477
/// This field keeps track of all the local variables that are declared mut and are mutated.
@@ -841,9 +843,9 @@ enum InitializationRequiringAction {
841
843
PartialAssignment ,
842
844
}
843
845
844
- struct RootPlace < ' d , ' tcx > {
846
+ struct RootPlace < ' tcx > {
845
847
place_local : Local ,
846
- place_projection : & ' d [ PlaceElem < ' tcx > ] ,
848
+ place_projection : & ' tcx [ PlaceElem < ' tcx > ] ,
847
849
is_local_mutation_allowed : LocalMutationIsAllowed ,
848
850
}
849
851
@@ -1413,7 +1415,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1413
1415
) {
1414
1416
debug ! ( "check_for_invalidation_at_exit({:?})" , borrow) ;
1415
1417
let place = & borrow. borrowed_place ;
1416
- let deref = [ ProjectionElem :: Deref ] ;
1417
1418
let mut root_place = PlaceRef { local : place. local , projection : & [ ] } ;
1418
1419
1419
1420
// FIXME(nll-rfc#40): do more precise destructor tracking here. For now
@@ -1427,7 +1428,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1427
1428
// Thread-locals might be dropped after the function exits
1428
1429
// We have to dereference the outer reference because
1429
1430
// borrows don't conflict behind shared references.
1430
- root_place. projection = & deref ;
1431
+ root_place. projection = DEREF_PROJECTION ;
1431
1432
( true , true )
1432
1433
} else {
1433
1434
( false , self . locals_are_invalidated_at_exit )
@@ -1526,7 +1527,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1526
1527
& mut self ,
1527
1528
location : Location ,
1528
1529
desired_action : InitializationRequiringAction ,
1529
- place_span : ( PlaceRef < ' cx , ' tcx > , Span ) ,
1530
+ place_span : ( PlaceRef < ' tcx > , Span ) ,
1530
1531
flow_state : & Flows < ' cx , ' tcx > ,
1531
1532
) {
1532
1533
let maybe_uninits = & flow_state. uninits ;
@@ -1592,7 +1593,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1592
1593
& mut self ,
1593
1594
location : Location ,
1594
1595
desired_action : InitializationRequiringAction ,
1595
- place_span : ( PlaceRef < ' cx , ' tcx > , Span ) ,
1596
+ place_span : ( PlaceRef < ' tcx > , Span ) ,
1596
1597
maybe_uninits : & BitSet < MovePathIndex > ,
1597
1598
from : u32 ,
1598
1599
to : u32 ,
@@ -1631,7 +1632,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1631
1632
& mut self ,
1632
1633
location : Location ,
1633
1634
desired_action : InitializationRequiringAction ,
1634
- place_span : ( PlaceRef < ' cx , ' tcx > , Span ) ,
1635
+ place_span : ( PlaceRef < ' tcx > , Span ) ,
1635
1636
flow_state : & Flows < ' cx , ' tcx > ,
1636
1637
) {
1637
1638
let maybe_uninits = & flow_state. uninits ;
@@ -1709,10 +1710,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1709
1710
/// An Err result includes a tag indicated why the search failed.
1710
1711
/// Currently this can only occur if the place is built off of a
1711
1712
/// 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 ) {
1716
1714
match self . move_data . rev_lookup . find ( place) {
1717
1715
LookupResult :: Parent ( Some ( mpi) ) | LookupResult :: Exact ( mpi) => {
1718
1716
( self . move_data . move_paths [ mpi] . place . as_ref ( ) , mpi)
@@ -1721,7 +1719,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1721
1719
}
1722
1720
}
1723
1721
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 > {
1725
1723
// If returns None, then there is no move path corresponding
1726
1724
// to a direct owner of `place` (which means there is nothing
1727
1725
// that borrowck tracks for its analysis).
@@ -1816,7 +1814,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1816
1814
fn check_parent_of_field < ' cx , ' tcx > (
1817
1815
this : & mut MirBorrowckCtxt < ' cx , ' tcx > ,
1818
1816
location : Location ,
1819
- base : PlaceRef < ' cx , ' tcx > ,
1817
+ base : PlaceRef < ' tcx > ,
1820
1818
span : Span ,
1821
1819
flow_state : & Flows < ' cx , ' tcx > ,
1822
1820
) {
@@ -2029,7 +2027,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2029
2027
}
2030
2028
2031
2029
/// 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 > ) {
2033
2031
match root_place {
2034
2032
RootPlace { place_local : local, place_projection : [ ] , is_local_mutation_allowed } => {
2035
2033
// If the local may have been initialized, and it is now currently being
@@ -2063,11 +2061,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2063
2061
2064
2062
/// Whether this value can be written or borrowed mutably.
2065
2063
/// Returns the root place if the place passed in is a projection.
2066
- fn is_mutable < ' d > (
2064
+ fn is_mutable (
2067
2065
& self ,
2068
- place : PlaceRef < ' d , ' tcx > ,
2066
+ place : PlaceRef < ' tcx > ,
2069
2067
is_local_mutation_allowed : LocalMutationIsAllowed ,
2070
- ) -> Result < RootPlace < ' d , ' tcx > , PlaceRef < ' d , ' tcx > > {
2068
+ ) -> Result < RootPlace < ' tcx > , PlaceRef < ' tcx > > {
2071
2069
match place {
2072
2070
PlaceRef { local, projection : [ ] } => {
2073
2071
let local = & self . body . local_decls [ local] ;
@@ -2218,7 +2216,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2218
2216
/// then returns the index of the field being projected. Note that this closure will always
2219
2217
/// be `self` in the current MIR, because that is the only time we directly access the fields
2220
2218
/// 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 > {
2222
2220
let mut place_projection = place_ref. projection ;
2223
2221
let mut by_ref = false ;
2224
2222
0 commit comments