@@ -364,12 +364,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
364364 }
365365 }
366366
367- // Taking a shared borrow of a `static` is always legal, even if that `static` has
368- // interior mutability.
367+ // At the moment, `PlaceBase::Static` is only used for promoted MIR.
369368 | Rvalue :: Ref ( _, BorrowKind :: Shared , ref place)
370369 | Rvalue :: Ref ( _, BorrowKind :: Shallow , ref place)
371370 if matches ! ( place. base, PlaceBase :: Static ( _) )
372- => { }
371+ => bug ! ( "Saw a promoted during const-checking, which must run before promotion" ) ,
373372
374373 | Rvalue :: Ref ( _, kind @ BorrowKind :: Shared , ref place)
375374 | Rvalue :: Ref ( _, kind @ BorrowKind :: Shallow , ref place)
@@ -708,8 +707,7 @@ fn place_as_reborrow(
708707 // A borrow of a `static` also looks like `&(*_1)` in the MIR, but `_1` is a `const`
709708 // that points to the allocation for the static. Don't treat these as reborrows.
710709 if let PlaceBase :: Local ( local) = place. base {
711- let decl = & body. local_decls [ local] ;
712- if let LocalInfo :: StaticRef { .. } = decl. local_info {
710+ if body. local_decls [ local] . is_ref_to_static ( ) {
713711 return None ;
714712 }
715713 }
0 commit comments