]> git.lizzy.rs Git - rust.git/commitdiff
Change sized_constraints to return EarlyBinder
authorJack Huey <31162821+jackh726@users.noreply.github.com>
Wed, 3 Aug 2022 04:14:24 +0000 (00:14 -0400)
committerJack Huey <31162821+jackh726@users.noreply.github.com>
Wed, 3 Aug 2022 04:14:24 +0000 (00:14 -0400)
compiler/rustc_middle/src/ty/adt.rs
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_ty_utils/src/ty.rs

index 809406aff1878879802042e00a5db620c572f206..2e596b275276e3bb86478e64552b3adf03dc66d6 100644 (file)
@@ -563,7 +563,7 @@ pub fn destructor(self, tcx: TyCtxt<'tcx>) -> Option<Destructor> {
     ///
     /// Due to normalization being eager, this applies even if
     /// the associated type is behind a pointer (e.g., issue #31299).
     ///
     /// Due to normalization being eager, this applies even if
     /// the associated type is behind a pointer (e.g., issue #31299).
-    pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> &'tcx [Ty<'tcx>] {
-        tcx.adt_sized_constraint(self.did()).0
+    pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
+        ty::EarlyBinder(tcx.adt_sized_constraint(self.did()).0)
     }
 }
     }
 }
index fb0a4b4e8f402a07dbc8f9396e4646e58638f580..52c3a38861e6531984603dc86497ea220e98bab1 100644 (file)
@@ -2191,7 +2191,7 @@ pub fn is_trivially_sized(self, tcx: TyCtxt<'tcx>) -> bool {
 
             ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
 
 
             ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
 
-            ty::Adt(def, _substs) => def.sized_constraint(tcx).is_empty(),
+            ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(),
 
             ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,
 
 
             ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,
 
index 155c1289876016ea0700e6f47c8e445dd11f5e5c..e828b13e7459c7ba8d146a8566da462c3f6733bb 100644 (file)
@@ -1883,7 +1883,11 @@ fn sized_conditions(
                 let sized_crit = def.sized_constraint(self.tcx());
                 // (*) binder moved here
                 Where(obligation.predicate.rebind({
                 let sized_crit = def.sized_constraint(self.tcx());
                 // (*) binder moved here
                 Where(obligation.predicate.rebind({
-                    sized_crit.iter().map(|ty| EarlyBinder(*ty).subst(self.tcx(), substs)).collect()
+                    sized_crit
+                        .0
+                        .iter()
+                        .map(|ty| sized_crit.rebind(*ty).subst(self.tcx(), substs))
+                        .collect()
                 }))
             }
 
                 }))
             }
 
index 7007e76b86e28f3b2dbea17db0c10e4b93d4617b..29582affc2ec71b401a2c1f76054bc8521f9b462 100644 (file)
@@ -33,8 +33,9 @@ fn sized_constraint_for_ty<'tcx>(
             let adt_tys = adt.sized_constraint(tcx);
             debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
             adt_tys
             let adt_tys = adt.sized_constraint(tcx);
             debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
             adt_tys
+                .0
                 .iter()
                 .iter()
-                .map(|ty| EarlyBinder(*ty).subst(tcx, substs))
+                .map(|ty| adt_tys.rebind(*ty).subst(tcx, substs))
                 .flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
                 .collect()
         }
                 .flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
                 .collect()
         }