Skip to content
/ rust Public
forked from rust-lang/rust

Commit 8696fa7

Browse files
Convert adt_sized_constraint to early-binder, use list
1 parent abd3637 commit 8696fa7

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ rustc_queries! {
706706
separate_provide_extern
707707
}
708708

709-
query adt_sized_constraint(key: DefId) -> &'tcx [Ty<'tcx>] {
709+
query adt_sized_constraint(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
710710
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
711711
}
712712

compiler/rustc_middle/src/ty/adt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ impl<'tcx> AdtDef<'tcx> {
572572
///
573573
/// Due to normalization being eager, this applies even if
574574
/// the associated type is behind a pointer (e.g., issue #31299).
575-
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
576-
ty::EarlyBinder::bind(tcx.adt_sized_constraint(self.did()))
575+
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
576+
tcx.adt_sized_constraint(self.did())
577577
}
578578
}
579579

compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
150150

151151
ty::Adt(def, args) => {
152152
let sized_crit = def.sized_constraint(ecx.tcx());
153-
Ok(sized_crit.iter_instantiated_copied(ecx.tcx(), args).collect())
153+
Ok(sized_crit.iter_instantiated(ecx.tcx(), args).collect())
154154
}
155155
}
156156
}

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
20992099
Where(
21002100
obligation
21012101
.predicate
2102-
.rebind(sized_crit.iter_instantiated_copied(self.tcx(), args).collect()),
2102+
.rebind(sized_crit.iter_instantiated(self.tcx(), args).collect()),
21032103
)
21042104
}
21052105

compiler/rustc_ty_utils/src/ty.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn sized_constraint_for_ty<'tcx>(
4242
let adt_tys = adt.sized_constraint(tcx);
4343
debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
4444
adt_tys
45-
.iter_instantiated_copied(tcx, args)
45+
.iter_instantiated(tcx, args)
4646
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
4747
.collect()
4848
}
@@ -92,10 +92,13 @@ fn defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
9292
/// - a tuple of type parameters or projections, if there are multiple
9393
/// such.
9494
/// - an Error, if a type is infinitely sized
95-
fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
95+
fn adt_sized_constraint<'tcx>(
96+
tcx: TyCtxt<'tcx>,
97+
def_id: DefId,
98+
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
9699
if let Some(def_id) = def_id.as_local() {
97100
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
98-
return tcx.mk_type_list(&[Ty::new_misc_error(tcx)]);
101+
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_misc_error(tcx)]));
99102
}
100103
}
101104
let def = tcx.adt_def(def_id);
@@ -107,7 +110,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
107110

108111
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
109112

110-
result
113+
ty::EarlyBinder::bind(result)
111114
}
112115

113116
/// See `ParamEnv` struct definition for details.

0 commit comments

Comments
 (0)