about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2024-12-18 13:07:47 +0100
committerlcnr <rust@lcnr.de>2024-12-18 13:07:47 +0100
commitc54e8157ddafac24b9e7027913117de6cf02736f (patch)
tree5f678f2e0c28557d43439b96419aab657d78b02a
parent5f90b15f09bf7f90aba8606db111577c1586c47e (diff)
downloadrust-c54e8157ddafac24b9e7027913117de6cf02736f.tar.gz
rust-c54e8157ddafac24b9e7027913117de6cf02736f.zip
rm TypeChecker::sanitize_type
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs20
1 files changed, 1 insertions, 19 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index 6e41000df81..bf814c4c0fb 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -267,7 +267,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
         debug!(?constant, ?location, "visit_const_operand");
 
         self.super_const_operand(constant, location);
-        let ty = self.sanitize_type(constant, constant.const_.ty());
+        let ty = constant.const_.ty();
 
         self.typeck.infcx.tcx.for_each_free_region(&ty, |live_region| {
             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> {
         }
     }
 
-    fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
-        self.super_rvalue(rvalue, location);
-        let rval_ty = rvalue.ty(self.body(), self.tcx());
-        self.sanitize_type(rvalue, rval_ty);
-    }
-
     fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) {
         self.super_local_decl(local, local_decl);
-        self.sanitize_type(local_decl, local_decl.ty);
 
         if let Some(user_ty) = &local_decl.user_ty {
             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> {
     }
 
     fn visit_body(&mut self, body: &Body<'tcx>) {
-        self.sanitize_type(&"return type", body.return_ty());
         // The types of local_decls are checked above which is called in super_body.
         self.super_body(body);
     }
@@ -449,14 +441,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
         self.typeck.infcx.tcx
     }
 
-    fn sanitize_type(&mut self, parent: &dyn fmt::Debug, ty: Ty<'tcx>) -> Ty<'tcx> {
-        if ty.has_escaping_bound_vars() || ty.references_error() {
-            span_mirbug_and_err!(self, parent, "bad type {:?}", ty)
-        } else {
-            ty
-        }
-    }
-
     /// Checks that the types internal to the `place` match up with
     /// what would be expected.
     #[instrument(level = "debug", skip(self, location), ret)]
@@ -642,7 +626,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
                 }
             },
             ProjectionElem::Field(field, fty) => {
-                let fty = self.sanitize_type(place, fty);
                 let fty = self.typeck.normalize(fty, location);
                 match self.field_ty(place, base, field, location) {
                     Ok(ty) => {
@@ -680,7 +663,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
                 bug!("ProjectionElem::Subtype shouldn't exist in borrowck")
             }
             ProjectionElem::OpaqueCast(ty) => {
-                let ty = self.sanitize_type(place, ty);
                 let ty = self.typeck.normalize(ty, location);
                 self.typeck
                     .relate_types(