Auto merge of #108112 - nnethercote:clarify-iterator-interners, r=oli-obk,compiler-errors

Clarify iterator interners

I found the iterator interners very confusing. This PR clarifies things.

r? `@compiler-errors`
This commit is contained in:
bors 2023-02-18 00:20:52 +00:00
commit a9842c73bc
36 changed files with 173 additions and 186 deletions

View file

@ -359,7 +359,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
let b_last_ty = b_tys.last().unwrap();
// Substitute just the tail field of B., and require that they're equal.
let unsized_a_ty = tcx.mk_tup(a_rest_tys.iter().chain([b_last_ty]));
let unsized_a_ty = tcx.mk_tup(a_rest_tys.iter().chain([b_last_ty]).copied());
let mut nested_goals = ecx.infcx.eq(goal.param_env, unsized_a_ty, b_ty)?;
// Similar to ADTs, require that the rest of the fields are equal.

View file

@ -191,10 +191,10 @@ pub(crate) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
ty::FnDef(def_id, substs) => Ok(Some(
tcx.fn_sig(def_id)
.subst(tcx, substs)
.map_bound(|sig| (tcx.mk_tup(sig.inputs().iter()), sig.output())),
.map_bound(|sig| (tcx.intern_tup(sig.inputs()), sig.output())),
)),
ty::FnPtr(sig) => {
Ok(Some(sig.map_bound(|sig| (tcx.mk_tup(sig.inputs().iter()), sig.output()))))
Ok(Some(sig.map_bound(|sig| (tcx.intern_tup(sig.inputs()), sig.output()))))
}
ty::Closure(_, substs) => {
let closure_substs = substs.as_closure();

View file

@ -2012,7 +2012,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let sig = match inputs.kind() {
ty::Tuple(inputs) if infcx.tcx.is_fn_trait(trait_ref.def_id()) => {
infcx.tcx.mk_fn_sig(
inputs.iter(),
*inputs,
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
@ -2023,7 +2023,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
)
}
_ => infcx.tcx.mk_fn_sig(
std::iter::once(inputs),
[inputs],
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,

View file

@ -1923,7 +1923,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
) -> Progress<'tcx> {
let tcx = selcx.tcx();
let self_ty = obligation.predicate.self_ty();
let substs = tcx.mk_substs([self_ty.into()].iter());
let substs = tcx.intern_substs(&[self_ty.into()]);
let lang_items = tcx.lang_items();
let item_def_id = obligation.predicate.def_id;
let trait_def_id = tcx.trait_of_item(item_def_id).unwrap();

View file

@ -564,10 +564,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.into()
}
});
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
let assoc_ty_substs = tcx.intern_substs(&substs);
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
let bound =
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))