@@ -8,7 +8,9 @@ use rustc::infer::InferCtxt;
8
8
use rustc:: lint:: builtin:: UNUSED_MUT ;
9
9
use rustc:: middle:: borrowck:: SignalledError ;
10
10
use rustc:: mir:: { AggregateKind , BasicBlock , BorrowCheckResult , BorrowKind } ;
11
- use rustc:: mir:: { ClearCrossCrate , Local , Location , Mir , Mutability , Operand , Place , PlaceBase } ;
11
+ use rustc:: mir:: {
12
+ ClearCrossCrate , Local , Location , Mir , Mutability , Operand , Place , PlaceBase , Static , StaticKind
13
+ } ;
12
14
use rustc:: mir:: { Field , Projection , ProjectionElem , Rvalue , Statement , StatementKind } ;
13
15
use rustc:: mir:: { Terminator , TerminatorKind } ;
14
16
use rustc:: ty:: query:: Providers ;
@@ -1226,8 +1228,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1226
1228
}
1227
1229
Operand :: Move ( Place :: Base ( PlaceBase :: Static ( ..) ) )
1228
1230
| Operand :: Copy ( Place :: Base ( PlaceBase :: Static ( ..) ) )
1229
- | Operand :: Move ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
1230
- | Operand :: Copy ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
1231
1231
| Operand :: Constant ( ..) => { }
1232
1232
}
1233
1233
}
@@ -1310,12 +1310,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1310
1310
//
1311
1311
// FIXME: allow thread-locals to borrow other thread locals?
1312
1312
let ( might_be_alive, will_be_dropped) = match root_place {
1313
- Place :: Base ( PlaceBase :: Promoted ( _) ) => ( true , false ) ,
1314
- Place :: Base ( PlaceBase :: Static ( _) ) => {
1313
+ Place :: Base ( PlaceBase :: Static ( box Static { kind : StaticKind :: Promoted ( _) , .. } ) ) => {
1314
+ ( true , false )
1315
+ }
1316
+ Place :: Base ( PlaceBase :: Static ( box Static { kind : StaticKind :: Static ( _) , .. } ) ) => {
1315
1317
// Thread-locals might be dropped after the function exits, but
1316
1318
// "true" statics will never be.
1317
- let is_thread_local = self . is_place_thread_local ( & root_place) ;
1318
- ( true , is_thread_local)
1319
+ ( true , self . is_place_thread_local ( & root_place) )
1319
1320
}
1320
1321
Place :: Base ( PlaceBase :: Local ( _) ) => {
1321
1322
// Locals are always dropped at function exit, and if they
@@ -1578,7 +1579,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1578
1579
match * last_prefix {
1579
1580
Place :: Base ( PlaceBase :: Local ( _) ) => panic ! ( "should have move path for every Local" ) ,
1580
1581
Place :: Projection ( _) => panic ! ( "PrefixSet::All meant don't stop for Projection" ) ,
1581
- Place :: Base ( PlaceBase :: Promoted ( _) ) |
1582
1582
Place :: Base ( PlaceBase :: Static ( _) ) => Err ( NoMovePathFound :: ReachedStatic ) ,
1583
1583
}
1584
1584
}
@@ -1605,7 +1605,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1605
1605
let mut place = place;
1606
1606
loop {
1607
1607
match * place {
1608
- Place :: Base ( PlaceBase :: Promoted ( _) ) |
1609
1608
Place :: Base ( PlaceBase :: Local ( _) ) | Place :: Base ( PlaceBase :: Static ( _) ) => {
1610
1609
// assigning to `x` does not require `x` be initialized.
1611
1610
break ;
@@ -1953,10 +1952,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1953
1952
self . used_mut_upvars . push ( field) ;
1954
1953
}
1955
1954
}
1956
- RootPlace {
1957
- place : Place :: Base ( PlaceBase :: Promoted ( ..) ) ,
1958
- is_local_mutation_allowed : _,
1959
- } => { }
1960
1955
RootPlace {
1961
1956
place : Place :: Base ( PlaceBase :: Static ( ..) ) ,
1962
1957
is_local_mutation_allowed : _,
@@ -1994,12 +1989,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1994
1989
}
1995
1990
// The rules for promotion are made by `qualify_consts`, there wouldn't even be a
1996
1991
// `Place::Promoted` if the promotion weren't 100% legal. So we just forward this
1997
- Place :: Base ( PlaceBase :: Promoted ( _) ) => Ok ( RootPlace {
1998
- place,
1999
- is_local_mutation_allowed,
2000
- } ) ,
2001
- Place :: Base ( PlaceBase :: Static ( ref static_) ) => {
2002
- if self . infcx . tcx . is_static ( static_. def_id ) != Some ( hir:: Mutability :: MutMutable ) {
1992
+ Place :: Base ( PlaceBase :: Static ( box Static { kind : StaticKind :: Promoted ( _) , ..} ) ) =>
1993
+ Ok ( RootPlace {
1994
+ place,
1995
+ is_local_mutation_allowed,
1996
+ } ) ,
1997
+ Place :: Base ( PlaceBase :: Static ( box Static { kind : StaticKind :: Static ( def_id) , .. } ) ) => {
1998
+ if self . infcx . tcx . is_static ( def_id) != Some ( hir:: Mutability :: MutMutable ) {
2003
1999
Err ( place)
2004
2000
} else {
2005
2001
Ok ( RootPlace {
0 commit comments