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
|
@ -240,7 +240,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
assert_matches!(self.def_kind(trait_def_id), DefKind::Trait);
|
||||
let trait_generics = self.generics_of(trait_def_id);
|
||||
(
|
||||
ty::TraitRef::new(self, trait_def_id, args.truncate_to(self, trait_generics)),
|
||||
ty::TraitRef::new_from_args(self, trait_def_id, args.truncate_to(self, trait_generics)),
|
||||
&args[trait_generics.count()..],
|
||||
)
|
||||
}
|
||||
|
@ -261,12 +261,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
self.check_args_compatible(def_id, args)
|
||||
}
|
||||
|
||||
fn check_and_mk_args(
|
||||
self,
|
||||
def_id: DefId,
|
||||
args: impl IntoIterator<Item: Into<ty::GenericArg<'tcx>>>,
|
||||
) -> ty::GenericArgsRef<'tcx> {
|
||||
self.check_and_mk_args(def_id, args)
|
||||
fn debug_assert_args_compatible(self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) {
|
||||
self.debug_assert_args_compatible(def_id, args);
|
||||
}
|
||||
|
||||
fn intern_canonical_goal_evaluation_step(
|
||||
|
|
|
@ -499,7 +499,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn new_opaque(tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
|
||||
Ty::new_alias(tcx, ty::Opaque, AliasTy::new(tcx, def_id, args))
|
||||
Ty::new_alias(tcx, ty::Opaque, AliasTy::new_from_args(tcx, def_id, args))
|
||||
}
|
||||
|
||||
/// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
|
||||
|
@ -669,6 +669,15 @@ impl<'tcx> Ty<'tcx> {
|
|||
Ty::new(tcx, Dynamic(obj, reg, repr))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_projection_from_args(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
item_def_id: DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
Ty::new_alias(tcx, ty::Projection, AliasTy::new_from_args(tcx, item_def_id, args))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_projection(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -1409,7 +1418,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
let assoc_items = tcx.associated_item_def_ids(
|
||||
tcx.require_lang_item(hir::LangItem::DiscriminantKind, None),
|
||||
);
|
||||
Ty::new_projection(tcx, assoc_items[0], tcx.mk_args(&[self.into()]))
|
||||
Ty::new_projection_from_args(tcx, assoc_items[0], tcx.mk_args(&[self.into()]))
|
||||
}
|
||||
|
||||
ty::Pat(ty, _) => ty.discriminant_ty(tcx),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue