@@ -8,7 +8,9 @@ use rustc::infer::InferCtxt;
88use rustc:: lint:: builtin:: UNUSED_MUT ;
99use rustc:: middle:: borrowck:: SignalledError ;
1010use 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+ } ;
1214use rustc:: mir:: { Field , Projection , ProjectionElem , Rvalue , Statement , StatementKind } ;
1315use rustc:: mir:: { Terminator , TerminatorKind } ;
1416use rustc:: ty:: query:: Providers ;
@@ -1226,8 +1228,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
12261228 }
12271229 Operand :: Move ( Place :: Base ( PlaceBase :: Static ( ..) ) )
12281230 | Operand :: Copy ( Place :: Base ( PlaceBase :: Static ( ..) ) )
1229- | Operand :: Move ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
1230- | Operand :: Copy ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
12311231 | Operand :: Constant ( ..) => { }
12321232 }
12331233 }
@@ -1310,12 +1310,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13101310 //
13111311 // FIXME: allow thread-locals to borrow other thread locals?
13121312 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 ( _) , .. } ) ) => {
13151317 // Thread-locals might be dropped after the function exits, but
13161318 // "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) )
13191320 }
13201321 Place :: Base ( PlaceBase :: Local ( _) ) => {
13211322 // Locals are always dropped at function exit, and if they
@@ -1578,7 +1579,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15781579 match * last_prefix {
15791580 Place :: Base ( PlaceBase :: Local ( _) ) => panic ! ( "should have move path for every Local" ) ,
15801581 Place :: Projection ( _) => panic ! ( "PrefixSet::All meant don't stop for Projection" ) ,
1581- Place :: Base ( PlaceBase :: Promoted ( _) ) |
15821582 Place :: Base ( PlaceBase :: Static ( _) ) => Err ( NoMovePathFound :: ReachedStatic ) ,
15831583 }
15841584 }
@@ -1605,7 +1605,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16051605 let mut place = place;
16061606 loop {
16071607 match * place {
1608- Place :: Base ( PlaceBase :: Promoted ( _) ) |
16091608 Place :: Base ( PlaceBase :: Local ( _) ) | Place :: Base ( PlaceBase :: Static ( _) ) => {
16101609 // assigning to `x` does not require `x` be initialized.
16111610 break ;
@@ -1953,10 +1952,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
19531952 self . used_mut_upvars . push ( field) ;
19541953 }
19551954 }
1956- RootPlace {
1957- place : Place :: Base ( PlaceBase :: Promoted ( ..) ) ,
1958- is_local_mutation_allowed : _,
1959- } => { }
19601955 RootPlace {
19611956 place : Place :: Base ( PlaceBase :: Static ( ..) ) ,
19621957 is_local_mutation_allowed : _,
@@ -1994,12 +1989,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
19941989 }
19951990 // The rules for promotion are made by `qualify_consts`, there wouldn't even be a
19961991 // `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 ) {
20031999 Err ( place)
20042000 } else {
20052001 Ok ( RootPlace {
0 commit comments