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