X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibrustc_mir%2Ftransform%2Fcheck_consts%2Fvalidation.rs;h=68bfa50a95289f942792856b97db3b3f59da7769;hb=ccb4eed3529eaf610f476dd6d78ecd159a897b64;hp=bc13764f0a3ed19c5c86e38e40460d827f1aaecf;hpb=846be82277fef758e033538d7d49a2e834e472c4;p=rust.git diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index bc13764f0a3..68bfa50a952 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -364,12 +364,11 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { } } - // Taking a shared borrow of a `static` is always legal, even if that `static` has - // interior mutability. + // At the moment, `PlaceBase::Static` is only used for promoted MIR. | Rvalue::Ref(_, BorrowKind::Shared, ref place) | Rvalue::Ref(_, BorrowKind::Shallow, ref place) if matches!(place.base, PlaceBase::Static(_)) - => {} + => bug!("Saw a promoted during const-checking, which must run before promotion"), | Rvalue::Ref(_, kind @ BorrowKind::Shared, ref place) | Rvalue::Ref(_, kind @ BorrowKind::Shallow, ref place) @@ -708,8 +707,7 @@ fn place_as_reborrow( // A borrow of a `static` also looks like `&(*_1)` in the MIR, but `_1` is a `const` // that points to the allocation for the static. Don't treat these as reborrows. if let PlaceBase::Local(local) = place.base { - let decl = &body.local_decls[local]; - if let LocalInfo::StaticRef { .. } = decl.local_info { + if body.local_decls[local].is_ref_to_static() { return None; } }