]> git.lizzy.rs Git - rust.git/commitdiff
do not implement type traversal for `EarlyBinder`
authorlcnr <rust@lcnr.de>
Fri, 16 Sep 2022 13:09:38 +0000 (15:09 +0200)
committerlcnr <rust@lcnr.de>
Mon, 19 Sep 2022 09:28:32 +0000 (11:28 +0200)
compiler/rustc_middle/src/ty/layout.rs
compiler/rustc_middle/src/ty/structural_impls.rs
compiler/rustc_middle/src/ty/sty.rs

index 042eeec3f4622eefcf41b8d547cb1e46ae715590..13a6cf190098d61f37146ffa0f4e0a8e3545a499 100644 (file)
@@ -2770,7 +2770,10 @@ fn fn_sig_for_fn_abi(
                 // track of a polymorphization `ParamEnv` to allow normalizing later.
                 let mut sig = match *ty.kind() {
                     ty::FnDef(def_id, substs) => tcx
-                        .normalize_erasing_regions(tcx.param_env(def_id), tcx.bound_fn_sig(def_id))
+                        .bound_fn_sig(def_id)
+                        .map_bound(|fn_sig| {
+                            tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
+                        })
                         .subst(tcx, substs),
                     _ => unreachable!(),
                 };
index f5fd1f6ffafce2ce0c16bb59ffa6d0c44c22fc9a..004fcffdc4074152cb8d1ae29f00fb9be00fe9f4 100644 (file)
@@ -557,18 +557,6 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
     }
 }
 
-impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::EarlyBinder<T> {
-    fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
-        self.try_map_bound(|ty| ty.try_fold_with(folder))
-    }
-}
-
-impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for ty::EarlyBinder<T> {
-    fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
-        self.as_ref().0.visit_with(visitor)
-    }
-}
-
 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> {
     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
         folder.try_fold_binder(self)
index 36e560850390451d2fbbb9681cc9d0824d078970..2d78c0c86563a49f392a02fce3950ba900ec078c 100644 (file)
@@ -919,6 +919,10 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTrai
 #[derive(Encodable, Decodable, HashStable)]
 pub struct EarlyBinder<T>(pub T);
 
+/// For early binders, you should first call `subst` before using any visitors.
+impl<'tcx, T> !TypeFoldable<'tcx> for ty::EarlyBinder<T> {}
+impl<'tcx, T> !TypeVisitable<'tcx> for ty::EarlyBinder<T> {}
+
 impl<T> EarlyBinder<T> {
     pub fn as_ref(&self) -> EarlyBinder<&T> {
         EarlyBinder(&self.0)