treat literals in ExprKind::StaticRef as mir::ConstantKind::Val

This commit is contained in:
b-naber 2022-03-07 13:51:59 +01:00
parent 1b14fd3b10
commit d92df974fe
6 changed files with 30 additions and 21 deletions

View file

@ -2534,7 +2534,7 @@ pub enum ConstantKind<'tcx> {
impl<'tcx> Constant<'tcx> {
pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
match self.literal.const_for_ty()?.val().try_to_scalar() {
match self.literal.try_to_scalar() {
Some(Scalar::Ptr(ptr, _size)) => match tcx.global_alloc(ptr.provenance) {
GlobalAlloc::Static(def_id) => {
assert!(!tcx.is_thread_local_static(def_id));