@@ -267,7 +267,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
267267 debug ! ( ?constant, ?location, "visit_const_operand" ) ;
268268
269269 self . super_const_operand ( constant, location) ;
270- let ty = self . sanitize_type ( constant, constant . const_ . ty ( ) ) ;
270+ let ty = constant. const_ . ty ( ) ;
271271
272272 self . typeck . infcx . tcx . for_each_free_region ( & ty, |live_region| {
273273 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> {
387387 }
388388 }
389389
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-
396390 fn visit_local_decl ( & mut self , local : Local , local_decl : & LocalDecl < ' tcx > ) {
397391 self . super_local_decl ( local, local_decl) ;
398- self . sanitize_type ( local_decl, local_decl. ty ) ;
399392
400393 if let Some ( user_ty) = & local_decl. user_ty {
401394 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> {
434427 }
435428
436429 fn visit_body ( & mut self , body : & Body < ' tcx > ) {
437- self . sanitize_type ( & "return type" , body. return_ty ( ) ) ;
438430 // The types of local_decls are checked above which is called in super_body.
439431 self . super_body ( body) ;
440432 }
@@ -449,14 +441,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
449441 self . typeck . infcx . tcx
450442 }
451443
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-
460444 /// Checks that the types internal to the `place` match up with
461445 /// what would be expected.
462446 #[ instrument( level = "debug" , skip( self , location) , ret) ]
@@ -642,7 +626,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
642626 }
643627 } ,
644628 ProjectionElem :: Field ( field, fty) => {
645- let fty = self . sanitize_type ( place, fty) ;
646629 let fty = self . typeck . normalize ( fty, location) ;
647630 match self . field_ty ( place, base, field, location) {
648631 Ok ( ty) => {
@@ -680,7 +663,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
680663 bug ! ( "ProjectionElem::Subtype shouldn't exist in borrowck" )
681664 }
682665 ProjectionElem :: OpaqueCast ( ty) => {
683- let ty = self . sanitize_type ( place, ty) ;
684666 let ty = self . typeck . normalize ( ty, location) ;
685667 self . typeck
686668 . relate_types (
0 commit comments