Split out IntoIterator and non-Iterator constructors for AliasTy/AliasTerm/TraitRef/projection
This commit is contained in:
parent
06c072f158
commit
f26cc349d9
35 changed files with 144 additions and 84 deletions
|
@ -719,7 +719,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
tcx,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
ty::TraitRef::new(tcx, def_id.to_def_id(), trait_args),
|
||||
ty::TraitRef::new_from_args(tcx, def_id.to_def_id(), trait_args),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -2032,7 +2032,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
// to its definition type. This should be the param-env we use to *prove* the
|
||||
// predicate too, but we don't do that because of performance issues.
|
||||
// See <https://github.com/rust-lang/rust/pull/117542#issue-1976337685>.
|
||||
let trait_projection_ty = Ty::new_projection(tcx, trait_ty.def_id, rebased_args);
|
||||
let trait_projection_ty = Ty::new_projection_from_args(tcx, trait_ty.def_id, rebased_args);
|
||||
let impl_identity_ty = tcx.type_of(impl_ty.def_id).instantiate_identity();
|
||||
let normalize_param_env = param_env_with_gat_bounds(tcx, impl_ty, impl_trait_ref);
|
||||
for mut obligation in util::elaborate(tcx, obligations) {
|
||||
|
@ -2230,7 +2230,11 @@ fn param_env_with_gat_bounds<'tcx>(
|
|||
_ => predicates.push(
|
||||
ty::Binder::bind_with_vars(
|
||||
ty::ProjectionPredicate {
|
||||
projection_term: ty::AliasTerm::new(tcx, trait_ty.def_id, rebased_args),
|
||||
projection_term: ty::AliasTerm::new_from_args(
|
||||
tcx,
|
||||
trait_ty.def_id,
|
||||
rebased_args,
|
||||
),
|
||||
term: normalize_impl_ty.into(),
|
||||
},
|
||||
bound_vars,
|
||||
|
|
|
@ -504,7 +504,11 @@ pub fn check_intrinsic_type(
|
|||
ty::Region::new_bound(tcx, ty::INNERMOST, br),
|
||||
param(0),
|
||||
)],
|
||||
Ty::new_projection(tcx, discriminant_def_id, tcx.mk_args(&[param(0).into()])),
|
||||
Ty::new_projection_from_args(
|
||||
tcx,
|
||||
discriminant_def_id,
|
||||
tcx.mk_args(&[param(0).into()]),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
|||
item_segment,
|
||||
trait_ref.args,
|
||||
);
|
||||
Ty::new_projection(self.tcx(), item_def_id, item_args)
|
||||
Ty::new_projection_from_args(self.tcx(), item_def_id, item_args)
|
||||
} else {
|
||||
// There are no late-bound regions; we can just ignore the binder.
|
||||
let (mut mpart_sugg, mut inferred_sugg) = (None, None);
|
||||
|
@ -1607,7 +1607,7 @@ pub fn suggest_impl_trait<'tcx>(
|
|||
let item_ty = ocx.normalize(
|
||||
&ObligationCause::dummy(),
|
||||
param_env,
|
||||
Ty::new_projection(infcx.tcx, assoc_item_def_id, args),
|
||||
Ty::new_projection_from_args(infcx.tcx, assoc_item_def_id, args),
|
||||
);
|
||||
// FIXME(compiler-errors): We may benefit from resolving regions here.
|
||||
if ocx.select_where_possible().is_empty()
|
||||
|
|
|
@ -23,7 +23,7 @@ fn associated_type_bounds<'tcx>(
|
|||
span: Span,
|
||||
filter: PredicateFilter,
|
||||
) -> &'tcx [(ty::Clause<'tcx>, Span)] {
|
||||
let item_ty = Ty::new_projection(
|
||||
let item_ty = Ty::new_projection_from_args(
|
||||
tcx,
|
||||
assoc_item_def_id.to_def_id(),
|
||||
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
|
||||
|
@ -108,7 +108,7 @@ pub(super) fn explicit_item_bounds_with_filter(
|
|||
tcx,
|
||||
opaque_def_id.expect_local(),
|
||||
opaque_ty.bounds,
|
||||
Ty::new_projection(
|
||||
Ty::new_projection_from_args(
|
||||
tcx,
|
||||
def_id.to_def_id(),
|
||||
ty::GenericArgs::identity_for_item(tcx, def_id),
|
||||
|
|
|
@ -409,7 +409,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
);
|
||||
debug!(?alias_args);
|
||||
|
||||
ty::AliasTerm::new(tcx, assoc_item.def_id, alias_args)
|
||||
ty::AliasTerm::new_from_args(tcx, assoc_item.def_id, alias_args)
|
||||
});
|
||||
|
||||
// Provide the resolved type of the associated constant to `type_of(AnonConst)`.
|
||||
|
|
|
@ -693,7 +693,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
debug!(?bound_vars);
|
||||
|
||||
let poly_trait_ref = ty::Binder::bind_with_vars(
|
||||
ty::TraitRef::new(tcx, trait_def_id, generic_args),
|
||||
ty::TraitRef::new_from_args(tcx, trait_def_id, generic_args),
|
||||
bound_vars,
|
||||
);
|
||||
|
||||
|
@ -759,7 +759,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
Some((trait_def_id, trait_segment, span)),
|
||||
);
|
||||
}
|
||||
ty::TraitRef::new(self.tcx(), trait_def_id, generic_args)
|
||||
ty::TraitRef::new_from_args(self.tcx(), trait_def_id, generic_args)
|
||||
}
|
||||
|
||||
fn probe_trait_that_defines_assoc_item(
|
||||
|
@ -789,7 +789,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
// Type aliases defined in crates that have the
|
||||
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
|
||||
// then actually instantiate the where bounds of.
|
||||
let alias_ty = ty::AliasTy::new(tcx, did, args);
|
||||
let alias_ty = ty::AliasTy::new_from_args(tcx, did, args);
|
||||
Ty::new_alias(tcx, ty::Weak, alias_ty)
|
||||
} else {
|
||||
tcx.at(span).type_of(did).instantiate(tcx, args)
|
||||
|
@ -1267,7 +1267,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
.chain(args.into_iter().skip(parent_args.len())),
|
||||
);
|
||||
|
||||
let ty = Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new(tcx, assoc_item, args));
|
||||
let ty =
|
||||
Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new_from_args(tcx, assoc_item, args));
|
||||
|
||||
Ok(Some((ty, assoc_item)))
|
||||
}
|
||||
|
@ -1534,7 +1535,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let item_args =
|
||||
self.lower_generic_args_of_assoc_item(span, item_def_id, item_segment, trait_ref.args);
|
||||
|
||||
Ty::new_projection(tcx, item_def_id, item_args)
|
||||
Ty::new_projection_from_args(tcx, item_def_id, item_args)
|
||||
}
|
||||
|
||||
pub fn prohibit_generic_args<'a>(
|
||||
|
@ -2302,7 +2303,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
debug!(?args);
|
||||
|
||||
if in_trait {
|
||||
Ty::new_projection(tcx, def_id, args)
|
||||
Ty::new_projection_from_args(tcx, def_id, args)
|
||||
} else {
|
||||
Ty::new_opaque(tcx, def_id, args)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue