@@ -455,52 +455,42 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
455455 } ,
456456 Place :: Base ( PlaceBase :: Static ( box Static { def_id, ty : sty, promoted } ) ) => {
457457 let sty = self . sanitize_type ( place, sty) ;
458+ let check_err =
459+ |verifier : & mut TypeVerifier < ' a , ' b , ' gcx , ' tcx > ,
460+ place : & Place < ' tcx > ,
461+ ty,
462+ sty| {
463+ if let Err ( terr) = verifier. cx . eq_types (
464+ sty,
465+ ty,
466+ location. to_locations ( ) ,
467+ ConstraintCategory :: Boring ,
468+ ) {
469+ span_mirbug ! (
470+ verifier,
471+ place,
472+ "bad promoted type ({:?}: {:?}): {:?}" ,
473+ ty,
474+ sty,
475+ terr
476+ ) ;
477+ } ;
478+ } ;
458479 match promoted {
459480 Some ( pr) => {
460481 if !self . errors_reported {
461482 let promoted_mir = & self . mir . promoted [ pr] ;
462483 self . sanitize_promoted ( promoted_mir, location) ;
463484
464485 let promoted_ty = promoted_mir. return_ty ( ) ;
465-
466- if let Err ( terr) = self . cx . eq_types (
467- sty,
468- promoted_ty,
469- location. to_locations ( ) ,
470- ConstraintCategory :: Boring ,
471- ) {
472- span_mirbug ! (
473- self ,
474- place,
475- "bad promoted type ({:?}: {:?}): {:?}" ,
476- promoted_ty,
477- sty,
478- terr
479- ) ;
480- } ;
486+ check_err ( self , place, promoted_ty, sty) ;
481487 }
482488 }
483489 None => {
484490 let ty = self . tcx ( ) . type_of ( def_id) ;
485491 let ty = self . cx . normalize ( ty, location) ;
486- if let Err ( terr) =
487- self . cx
488- . eq_types (
489- ty,
490- sty,
491- location. to_locations ( ) ,
492- ConstraintCategory :: Boring
493- )
494- {
495- span_mirbug ! (
496- self ,
497- place,
498- "bad static type ({:?}: {:?}): {:?}" ,
499- ty,
500- sty,
501- terr
502- ) ;
503- } ;
492+
493+ check_err ( self , place, ty, sty) ;
504494 }
505495 }
506496 PlaceTy :: Ty { ty : sty }
0 commit comments