Rework most of structural_traits to be Interner-agnostic
This commit is contained in:
parent
d3812ac95f
commit
b79360ad16
10 changed files with 349 additions and 138 deletions
|
@ -204,6 +204,23 @@ impl<'tcx> rustc_type_ir::inherent::AdtDef<TyCtxt<'tcx>> for AdtDef<'tcx> {
|
|||
fn def_id(self) -> DefId {
|
||||
self.did()
|
||||
}
|
||||
|
||||
fn is_phantom_data(self) -> bool {
|
||||
self.is_phantom_data()
|
||||
}
|
||||
|
||||
fn all_field_tys(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> ty::EarlyBinder<'tcx, impl Iterator<Item = Ty<'tcx>>> {
|
||||
ty::EarlyBinder::bind(
|
||||
self.all_fields().map(move |field| tcx.type_of(field.did).skip_binder()),
|
||||
)
|
||||
}
|
||||
|
||||
fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> Option<ty::EarlyBinder<'tcx, Ty<'tcx>>> {
|
||||
self.sized_constraint(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, HashStable, TyEncodable, TyDecodable)]
|
||||
|
|
|
@ -154,7 +154,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
|
||||
type VariancesOf = &'tcx [ty::Variance];
|
||||
|
||||
fn variances_of(self, def_id: Self::DefId) -> Self::VariancesOf {
|
||||
fn variances_of(self, def_id: DefId) -> Self::VariancesOf {
|
||||
self.variances_of(def_id)
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
|
||||
fn trait_ref_and_own_args_for_alias(
|
||||
self,
|
||||
def_id: Self::DefId,
|
||||
def_id: DefId,
|
||||
args: Self::GenericArgs,
|
||||
) -> (rustc_type_ir::TraitRef<Self>, Self::GenericArgsSlice) {
|
||||
assert_matches!(self.def_kind(def_id), DefKind::AssocTy | DefKind::AssocConst);
|
||||
|
@ -246,7 +246,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
self.mk_type_list_from_iter(args)
|
||||
}
|
||||
|
||||
fn parent(self, def_id: Self::DefId) -> Self::DefId {
|
||||
fn parent(self, def_id: DefId) -> DefId {
|
||||
self.parent(def_id)
|
||||
}
|
||||
|
||||
|
@ -259,6 +259,49 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
fn features(self) -> Self::Features {
|
||||
self.features()
|
||||
}
|
||||
|
||||
fn bound_coroutine_hidden_types(
|
||||
self,
|
||||
def_id: DefId,
|
||||
) -> impl Iterator<Item = ty::EarlyBinder<'tcx, ty::Binder<'tcx, Ty<'tcx>>>> {
|
||||
self.bound_coroutine_hidden_types(def_id)
|
||||
}
|
||||
|
||||
fn fn_sig(self, def_id: DefId) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> {
|
||||
self.fn_sig(def_id)
|
||||
}
|
||||
|
||||
fn coroutine_movability(self, def_id: DefId) -> rustc_ast::Movability {
|
||||
self.coroutine_movability(def_id)
|
||||
}
|
||||
|
||||
fn coroutine_for_closure(self, def_id: DefId) -> DefId {
|
||||
self.coroutine_for_closure(def_id)
|
||||
}
|
||||
|
||||
fn generics_require_sized_self(self, def_id: DefId) -> bool {
|
||||
self.generics_require_sized_self(def_id)
|
||||
}
|
||||
|
||||
fn item_bounds(
|
||||
self,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'tcx, impl Iterator<Item = ty::Clause<'tcx>>> {
|
||||
self.item_bounds(def_id).map_bound(IntoIterator::into_iter)
|
||||
}
|
||||
|
||||
fn super_predicates_of(
|
||||
self,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'tcx, impl Iterator<Item = ty::Clause<'tcx>>> {
|
||||
ty::EarlyBinder::bind(
|
||||
self.super_predicates_of(def_id).instantiate_identity(self).predicates.into_iter(),
|
||||
)
|
||||
}
|
||||
|
||||
fn has_target_features(self, def_id: DefId) -> bool {
|
||||
!self.codegen_fn_attrs(def_id).target_features.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for abi::Abi {
|
||||
|
@ -281,6 +324,10 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
|
|||
fn generic_const_exprs(self) -> bool {
|
||||
self.generic_const_exprs
|
||||
}
|
||||
|
||||
fn coroutine_clone(self) -> bool {
|
||||
self.coroutine_clone
|
||||
}
|
||||
}
|
||||
|
||||
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
|
||||
|
|
|
@ -41,6 +41,8 @@ pub struct GenericArg<'tcx> {
|
|||
marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>)>,
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::GenericArg<TyCtxt<'tcx>> for GenericArg<'tcx> {}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::GenericArgs<TyCtxt<'tcx>> for ty::GenericArgsRef<'tcx> {
|
||||
fn type_at(self, i: usize) -> Ty<'tcx> {
|
||||
self.type_at(i)
|
||||
|
|
|
@ -488,6 +488,8 @@ pub struct Term<'tcx> {
|
|||
marker: PhantomData<(Ty<'tcx>, Const<'tcx>)>,
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Term<TyCtxt<'tcx>> for Term<'tcx> {}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
|
||||
type Kind = TermKind<'tcx>;
|
||||
|
||||
|
|
|
@ -786,6 +786,10 @@ impl<'tcx> rustc_type_ir::inherent::Ty<TyCtxt<'tcx>> for Ty<'tcx> {
|
|||
tcx.types.bool
|
||||
}
|
||||
|
||||
fn new_u8(tcx: TyCtxt<'tcx>) -> Self {
|
||||
tcx.types.u8
|
||||
}
|
||||
|
||||
fn new_infer(tcx: TyCtxt<'tcx>, infer: ty::InferTy) -> Self {
|
||||
Ty::new_infer(tcx, infer)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue