diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index d08b8bb12913..e224febd3c92 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -965,7 +965,7 @@ pub(super) fn relate_rigid_alias_non_alias( // Alternatively we could modify `Equate` for this case by adding another // variant to `StructurallyRelateAliases`. let identity_args = self.fresh_args_for_item(alias.def_id()); - let rigid_ctor = ty::AliasTerm::new_from_args(cx, alias.kind, identity_args); + let rigid_ctor = alias.with_args(cx, identity_args); let ctor_term = rigid_ctor.to_term(cx); let obligations = self.delegate.eq_structurally_relating_aliases( param_env, diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 56aceccfade4..5423e394119c 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1340,11 +1340,7 @@ fn confirm_coroutine_candidate<'cx, 'tcx>( }; let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new_from_args( - tcx, - obligation.predicate.kind, - trait_ref.args, - ), + projection_term: obligation.predicate.with_args(tcx, trait_ref.args), term: ty.into(), }; @@ -1388,11 +1384,7 @@ fn confirm_future_candidate<'cx, 'tcx>( debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id()).name(), sym::Output); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new_from_args( - tcx, - obligation.predicate.kind, - trait_ref.args, - ), + projection_term: obligation.predicate.with_args(tcx, trait_ref.args), term: return_ty.into(), }; @@ -1434,11 +1426,7 @@ fn confirm_iterator_candidate<'cx, 'tcx>( debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id()).name(), sym::Item); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new_from_args( - tcx, - obligation.predicate.kind, - trait_ref.args, - ), + projection_term: obligation.predicate.with_args(tcx, trait_ref.args), term: yield_ty.into(), }; @@ -1488,11 +1476,7 @@ fn confirm_async_iterator_candidate<'cx, 'tcx>( let item_ty = args.type_at(0); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new_from_args( - tcx, - obligation.predicate.kind, - trait_ref.args, - ), + projection_term: obligation.predicate.with_args(tcx, trait_ref.args), term: item_ty.into(), }; @@ -1898,11 +1882,7 @@ fn confirm_async_fn_kind_helper_candidate<'cx, 'tcx>( }; let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new_from_args( - selcx.tcx(), - obligation.predicate.kind, - obligation.predicate.args, - ), + projection_term: obligation.predicate.with_args(selcx.tcx(), obligation.predicate.args), term: ty::CoroutineClosureSignature::tupled_upvars_by_closure_kind( selcx.tcx(), goal_kind_ty.expect_ty().to_opt_closure_kind().unwrap(), diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index dc215587b5fb..e70a802bcfbe 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -769,6 +769,10 @@ pub fn to_term(self, interner: I) -> I::Term { Ty::new_alias(interner, ty::AliasTy::new_from_args(interner, alias_ty_kind, self.args)) .into() } + + pub fn with_args(self, interner: I, args: I::GenericArgs) -> Self { + Self::new_from_args(interner, self.kind, args) + } } /// The following methods work only with (trait) associated term projections. diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 0ab7b24de713..9e5be99279ee 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -256,7 +256,7 @@ fn relate>( relate_args_invariantly(relation, a.args, b.args)? } }; - Ok(ty::AliasTerm::new_from_args(relation.cx(), a.kind, args)) + Ok(a.with_args(relation.cx(), args)) } } }