@@ -1226,8 +1226,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
12261226 }
12271227 Operand :: Move ( Place :: Base ( PlaceBase :: Static ( ..) ) )
12281228 | Operand :: Copy ( Place :: Base ( PlaceBase :: Static ( ..) ) )
1229- | Operand :: Move ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
1230- | Operand :: Copy ( Place :: Base ( PlaceBase :: Promoted ( ..) ) )
12311229 | Operand :: Constant ( ..) => { }
12321230 }
12331231 }
@@ -1310,12 +1308,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13101308 //
13111309 // FIXME: allow thread-locals to borrow other thread locals?
13121310 let ( might_be_alive, will_be_dropped) = match root_place {
1313- Place :: Base ( PlaceBase :: Promoted ( _) ) => ( true , false ) ,
1314- Place :: Base ( PlaceBase :: Static ( _) ) => {
1315- // Thread-locals might be dropped after the function exits, but
1316- // "true" statics will never be.
1317- let is_thread_local = self . is_place_thread_local ( & root_place) ;
1318- ( true , is_thread_local)
1311+ Place :: Base ( PlaceBase :: Static ( st) ) => {
1312+ match st. promoted {
1313+ None => {
1314+ // Thread-locals might be dropped after the function exits, but
1315+ // "true" statics will never be.
1316+ let is_thread_local = self . is_place_thread_local ( & root_place) ;
1317+ ( true , is_thread_local)
1318+ }
1319+ Some ( _) => ( true , false ) ,
1320+ }
13191321 }
13201322 Place :: Base ( PlaceBase :: Local ( _) ) => {
13211323 // Locals are always dropped at function exit, and if they
@@ -1578,7 +1580,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15781580 match * last_prefix {
15791581 Place :: Base ( PlaceBase :: Local ( _) ) => panic ! ( "should have move path for every Local" ) ,
15801582 Place :: Projection ( _) => panic ! ( "PrefixSet::All meant don't stop for Projection" ) ,
1581- Place :: Base ( PlaceBase :: Promoted ( _) ) |
15821583 Place :: Base ( PlaceBase :: Static ( _) ) => Err ( NoMovePathFound :: ReachedStatic ) ,
15831584 }
15841585 }
@@ -1605,7 +1606,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16051606 let mut place = place;
16061607 loop {
16071608 match * place {
1608- Place :: Base ( PlaceBase :: Promoted ( _) ) |
16091609 Place :: Base ( PlaceBase :: Local ( _) ) | Place :: Base ( PlaceBase :: Static ( _) ) => {
16101610 // assigning to `x` does not require `x` be initialized.
16111611 break ;
@@ -1953,10 +1953,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
19531953 self . used_mut_upvars . push ( field) ;
19541954 }
19551955 }
1956- RootPlace {
1957- place : Place :: Base ( PlaceBase :: Promoted ( ..) ) ,
1958- is_local_mutation_allowed : _,
1959- } => { }
19601956 RootPlace {
19611957 place : Place :: Base ( PlaceBase :: Static ( ..) ) ,
19621958 is_local_mutation_allowed : _,
@@ -1994,18 +1990,28 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
19941990 }
19951991 // The rules for promotion are made by `qualify_consts`, there wouldn't even be a
19961992 // `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- } ) ,
1993+ // Place::Base(PlaceBase::Promoted(_)) => Ok(RootPlace {
1994+ // place,
1995+ // is_local_mutation_allowed,
1996+ // }),
20011997 Place :: Base ( PlaceBase :: Static ( ref static_) ) => {
2002- if self . infcx . tcx . is_static ( static_. def_id ) != Some ( hir:: Mutability :: MutMutable ) {
2003- Err ( place)
2004- } else {
2005- Ok ( RootPlace {
2006- place,
2007- is_local_mutation_allowed,
2008- } )
1998+ match static_. promoted {
1999+ Some ( _) => {
2000+ Ok ( RootPlace {
2001+ place,
2002+ is_local_mutation_allowed,
2003+ } )
2004+ }
2005+ None => {
2006+ if self . infcx . tcx . is_static ( static_. def_id ) != Some ( hir:: Mutability :: MutMutable ) {
2007+ Err ( place)
2008+ } else {
2009+ Ok ( RootPlace {
2010+ place,
2011+ is_local_mutation_allowed,
2012+ } )
2013+ }
2014+ }
20092015 }
20102016 }
20112017 Place :: Projection ( ref proj) => {
0 commit comments