@@ -326,12 +326,15 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
326
326
) ;
327
327
}
328
328
} else {
329
+ let tcx = self . tcx ( ) ;
329
330
if let ty:: ConstKind :: Unevaluated ( def_id, substs) = constant. literal . val {
330
331
if let Err ( terr) = self . cx . fully_perform_op (
331
332
location. to_locations ( ) ,
332
333
ConstraintCategory :: Boring ,
333
334
self . cx . param_env . and ( type_op:: ascribe_user_type:: AscribeUserType :: new (
334
- constant. literal . ty , def_id, UserSubsts { substs, user_self_ty : None } ,
335
+ constant. literal . ty ,
336
+ def_id,
337
+ UserSubsts { substs, user_self_ty : None } ,
335
338
) ) ,
336
339
) {
337
340
span_mirbug ! (
@@ -342,10 +345,22 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
342
345
terr
343
346
) ;
344
347
}
348
+ } else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
349
+ let unnormalized_ty = tcx. type_of ( static_def_id) ;
350
+ let locations = location. to_locations ( ) ;
351
+ let normalized_ty = self . cx . normalize ( unnormalized_ty, locations) ;
352
+ let literal_ty = constant. literal . ty . builtin_deref ( true ) . unwrap ( ) . ty ;
353
+
354
+ if let Err ( terr) = self . cx . eq_types (
355
+ normalized_ty,
356
+ literal_ty,
357
+ locations,
358
+ ConstraintCategory :: Boring ,
359
+ ) {
360
+ span_mirbug ! ( self , constant, "bad static type {:?} ({:?})" , constant, terr) ;
361
+ }
345
362
}
346
363
if let ty:: FnDef ( def_id, substs) = constant. literal . ty . kind {
347
- let tcx = self . tcx ( ) ;
348
-
349
364
let instantiated_predicates = tcx
350
365
. predicates_of ( def_id)
351
366
. instantiate ( tcx, substs) ;
0 commit comments