@@ -309,6 +309,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
309309 ) ;
310310 }
311311 } else {
312+ let tcx = self . tcx ( ) ;
312313 if let ty:: ConstKind :: Unevaluated ( def_id, substs, promoted) = constant. literal . val {
313314 if let Some ( promoted) = promoted {
314315 let check_err = |verifier : & mut TypeVerifier < ' a , ' b , ' tcx > ,
@@ -358,10 +359,23 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
358359 ) ;
359360 }
360361 }
362+ } else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
363+ let unnormalized_ty = tcx. type_of ( static_def_id) ;
364+ let locations = location. to_locations ( ) ;
365+ let normalized_ty = self . cx . normalize ( unnormalized_ty, locations) ;
366+ let literal_ty = constant. literal . ty . builtin_deref ( true ) . unwrap ( ) . ty ;
367+
368+ if let Err ( terr) = self . cx . eq_types (
369+ normalized_ty,
370+ literal_ty,
371+ locations,
372+ ConstraintCategory :: Boring ,
373+ ) {
374+ span_mirbug ! ( self , constant, "bad static type {:?} ({:?})" , constant, terr) ;
375+ }
361376 }
362- if let ty:: FnDef ( def_id, substs) = constant. literal . ty . kind {
363- let tcx = self . tcx ( ) ;
364377
378+ if let ty:: FnDef ( def_id, substs) = constant. literal . ty . kind {
365379 let instantiated_predicates = tcx. predicates_of ( def_id) . instantiate ( tcx, substs) ;
366380 self . cx . normalize_and_prove_instantiated_predicates (
367381 instantiated_predicates,
0 commit comments