@@ -267,7 +267,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
267
267
debug ! ( ?constant, ?location, "visit_const_operand" ) ;
268
268
269
269
self . super_const_operand ( constant, location) ;
270
- let ty = self . sanitize_type ( constant, constant . const_ . ty ( ) ) ;
270
+ let ty = constant. const_ . ty ( ) ;
271
271
272
272
self . typeck . infcx . tcx . for_each_free_region ( & ty, |live_region| {
273
273
let live_region_vid = self . typeck . universal_regions . to_region_vid ( live_region) ;
@@ -387,15 +387,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
387
387
}
388
388
}
389
389
390
- fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
391
- self . super_rvalue ( rvalue, location) ;
392
- let rval_ty = rvalue. ty ( self . body ( ) , self . tcx ( ) ) ;
393
- self . sanitize_type ( rvalue, rval_ty) ;
394
- }
395
-
396
390
fn visit_local_decl ( & mut self , local : Local , local_decl : & LocalDecl < ' tcx > ) {
397
391
self . super_local_decl ( local, local_decl) ;
398
- self . sanitize_type ( local_decl, local_decl. ty ) ;
399
392
400
393
if let Some ( user_ty) = & local_decl. user_ty {
401
394
for ( user_ty, span) in user_ty. projections_and_spans ( ) {
@@ -434,7 +427,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
434
427
}
435
428
436
429
fn visit_body ( & mut self , body : & Body < ' tcx > ) {
437
- self . sanitize_type ( & "return type" , body. return_ty ( ) ) ;
438
430
// The types of local_decls are checked above which is called in super_body.
439
431
self . super_body ( body) ;
440
432
}
@@ -449,14 +441,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
449
441
self . typeck . infcx . tcx
450
442
}
451
443
452
- fn sanitize_type ( & mut self , parent : & dyn fmt:: Debug , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
453
- if ty. has_escaping_bound_vars ( ) || ty. references_error ( ) {
454
- span_mirbug_and_err ! ( self , parent, "bad type {:?}" , ty)
455
- } else {
456
- ty
457
- }
458
- }
459
-
460
444
/// Checks that the types internal to the `place` match up with
461
445
/// what would be expected.
462
446
#[ instrument( level = "debug" , skip( self , location) , ret) ]
@@ -642,7 +626,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
642
626
}
643
627
} ,
644
628
ProjectionElem :: Field ( field, fty) => {
645
- let fty = self . sanitize_type ( place, fty) ;
646
629
let fty = self . typeck . normalize ( fty, location) ;
647
630
match self . field_ty ( place, base, field, location) {
648
631
Ok ( ty) => {
@@ -680,7 +663,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
680
663
bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" )
681
664
}
682
665
ProjectionElem :: OpaqueCast ( ty) => {
683
- let ty = self . sanitize_type ( place, ty) ;
684
666
let ty = self . typeck . normalize ( ty, location) ;
685
667
self . typeck
686
668
. relate_types (
0 commit comments