@@ -364,12 +364,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
364
364
}
365
365
}
366
366
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.
369
368
| Rvalue :: Ref ( _, BorrowKind :: Shared , ref place)
370
369
| Rvalue :: Ref ( _, BorrowKind :: Shallow , ref place)
371
370
if matches ! ( place. base, PlaceBase :: Static ( _) )
372
- => { }
371
+ => bug ! ( "Saw a promoted during const-checking, which must run before promotion" ) ,
373
372
374
373
| Rvalue :: Ref ( _, kind @ BorrowKind :: Shared , ref place)
375
374
| Rvalue :: Ref ( _, kind @ BorrowKind :: Shallow , ref place)
@@ -708,8 +707,7 @@ fn place_as_reborrow(
708
707
// A borrow of a `static` also looks like `&(*_1)` in the MIR, but `_1` is a `const`
709
708
// that points to the allocation for the static. Don't treat these as reborrows.
710
709
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 ( ) {
713
711
return None ;
714
712
}
715
713
}
0 commit comments