diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-08-03 00:14:24 -0400 |
|---|---|---|
| committer | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-08-03 00:14:24 -0400 |
| commit | 96a69dce2c2831417c9019d941f50466cd8f2c0a (patch) | |
| tree | 9532c1586c8a63e86ba93b0c3eead3d3301f49ce | |
| parent | e21624dc80a455ecbd7de6d45524becf20b35ed2 (diff) | |
| download | rust-96a69dce2c2831417c9019d941f50466cd8f2c0a.tar.gz rust-96a69dce2c2831417c9019d941f50466cd8f2c0a.zip | |
Change sized_constraints to return EarlyBinder
| -rw-r--r-- | compiler/rustc_middle/src/ty/adt.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 3 |
4 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 809406aff18..2e596b27527 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -563,7 +563,7 @@ impl<'tcx> AdtDef<'tcx> { /// /// 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) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index fb0a4b4e8f4..52c3a38861e 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2191,7 +2191,7 @@ impl<'tcx> Ty<'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, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 155c1289876..e828b13e745 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1883,7 +1883,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { 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() })) } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 7007e76b86e..29582affc2e 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -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 + .0 .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() } |
