Auto merge of #124982 - compiler-errors:uplift-trait-ref, r=lcnr
Uplift `TraitRef` into `rustc_type_ir` Emotional rollercoaster r? lcnr
This commit is contained in:
commit
19dacee0d8
55 changed files with 492 additions and 313 deletions
|
@ -57,7 +57,7 @@ macro_rules! span_bug {
|
|||
macro_rules! TrivialLiftImpls {
|
||||
($($ty:ty),+ $(,)?) => {
|
||||
$(
|
||||
impl<'tcx> $crate::ty::Lift<'tcx> for $ty {
|
||||
impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty {
|
||||
type Lifted = Self;
|
||||
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
|
||||
Some(self)
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hir::def::{DefKind, Res};
|
|||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
|
||||
use rustc_type_ir::ConstKind as IrConstKind;
|
||||
use rustc_type_ir::{ConstTy, IntoKind, TypeFlags, WithCachedTypeInfo};
|
||||
use rustc_type_ir::{TypeFlags, WithCachedTypeInfo};
|
||||
|
||||
mod int;
|
||||
mod kind;
|
||||
|
@ -30,7 +30,7 @@ rustc_data_structures::static_assert_size!(ConstKind<'_>, 32);
|
|||
#[rustc_pass_by_value]
|
||||
pub struct Const<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<ConstData<'tcx>>>);
|
||||
|
||||
impl<'tcx> IntoKind for Const<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::IntoKind for Const<'tcx> {
|
||||
type Kind = ConstKind<'tcx>;
|
||||
|
||||
fn kind(self) -> ConstKind<'tcx> {
|
||||
|
@ -48,12 +48,6 @@ impl<'tcx> rustc_type_ir::visit::Flags for Const<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ConstTy<TyCtxt<'tcx>> for Const<'tcx> {
|
||||
fn ty(self) -> Ty<'tcx> {
|
||||
self.ty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Typed constant value.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(HashStable, TyEncodable, TyDecodable)]
|
||||
|
@ -180,7 +174,7 @@ impl<'tcx> Const<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::new::Const<TyCtxt<'tcx>> for Const<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::Const<TyCtxt<'tcx>> for Const<'tcx> {
|
||||
fn new_anon_bound(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
|
@ -189,6 +183,10 @@ impl<'tcx> rustc_type_ir::new::Const<TyCtxt<'tcx>> for Const<'tcx> {
|
|||
) -> Self {
|
||||
Const::new_bound(tcx, debruijn, var, ty)
|
||||
}
|
||||
|
||||
fn ty(self) -> Ty<'tcx> {
|
||||
self.ty()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Const<'tcx> {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
pub mod tls;
|
||||
|
||||
pub use rustc_type_ir::lift::Lift;
|
||||
|
||||
use crate::arena::Arena;
|
||||
use crate::dep_graph::{DepGraph, DepKindStruct};
|
||||
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
|
||||
|
@ -138,6 +140,19 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
|
||||
self.mk_canonical_var_infos(infos)
|
||||
}
|
||||
|
||||
type GenericsOf = &'tcx ty::Generics;
|
||||
fn generics_of(self, def_id: DefId) -> &'tcx ty::Generics {
|
||||
self.generics_of(def_id)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
|
||||
|
@ -917,7 +932,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn lift<T: Lift<'tcx>>(self, value: T) -> Option<T::Lifted> {
|
||||
pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
|
||||
value.lift_to_tcx(self)
|
||||
}
|
||||
|
||||
|
@ -1524,31 +1539,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A trait implemented for all `X<'a>` types that can be safely and
|
||||
/// efficiently converted to `X<'tcx>` as long as they are part of the
|
||||
/// provided `TyCtxt<'tcx>`.
|
||||
/// This can be done, for example, for `Ty<'tcx>` or `GenericArgsRef<'tcx>`
|
||||
/// by looking them up in their respective interners.
|
||||
///
|
||||
/// However, this is still not the best implementation as it does
|
||||
/// need to compare the components, even for interned values.
|
||||
/// It would be more efficient if `TypedArena` provided a way to
|
||||
/// determine whether the address is in the allocated range.
|
||||
///
|
||||
/// `None` is returned if the value or one of the components is not part
|
||||
/// of the provided context.
|
||||
/// For `Ty`, `None` can be returned if either the type interner doesn't
|
||||
/// contain the `TyKind` key or if the address of the interned
|
||||
/// pointer differs. The latter case is possible if a primitive type,
|
||||
/// e.g., `()` or `u8`, was interned in a different context.
|
||||
pub trait Lift<'tcx>: fmt::Debug {
|
||||
type Lifted: fmt::Debug + 'tcx;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted>;
|
||||
}
|
||||
|
||||
macro_rules! nop_lift {
|
||||
($set:ident; $ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for $ty {
|
||||
type Lifted = $lifted;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
// Assert that the set has the right type.
|
||||
|
@ -1583,7 +1576,7 @@ macro_rules! nop_lift {
|
|||
|
||||
macro_rules! nop_list_lift {
|
||||
($set:ident; $ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
|
||||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a List<$ty> {
|
||||
type Lifted = &'tcx List<$lifted>;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
// Assert that the set has the right type.
|
||||
|
@ -1621,7 +1614,7 @@ nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}
|
|||
|
||||
macro_rules! nop_slice_lift {
|
||||
($ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for &'a [$ty] {
|
||||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a [$ty] {
|
||||
type Lifted = &'tcx [$lifted];
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if self.is_empty() {
|
||||
|
|
|
@ -39,6 +39,16 @@ pub struct GenericArg<'tcx> {
|
|||
marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, ty::Const<'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)
|
||||
}
|
||||
|
||||
fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
|
||||
GenericArgs::identity_for_item(tcx, def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(parallel_compiler)]
|
||||
unsafe impl<'tcx> rustc_data_structures::sync::DynSend for GenericArg<'tcx> where
|
||||
&'tcx (Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>): rustc_data_structures::sync::DynSend
|
||||
|
@ -205,7 +215,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a> {
|
||||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
|
||||
type Lifted = GenericArg<'tcx>;
|
||||
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
|
|
|
@ -145,6 +145,12 @@ pub struct Generics {
|
|||
pub host_effect_index: Option<usize>,
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::GenericsOf<TyCtxt<'tcx>> for &'tcx Generics {
|
||||
fn count(&self) -> usize {
|
||||
self.parent_count + self.own_params.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Generics {
|
||||
/// Looks through the generics and all parents to find the index of the
|
||||
/// given param def-id. This is in comparison to the `param_def_id_to_index`
|
||||
|
|
|
@ -530,7 +530,7 @@ pub struct CReaderCacheKey {
|
|||
#[rustc_pass_by_value]
|
||||
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
|
||||
|
||||
impl<'tcx> IntoKind for Ty<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> {
|
||||
type Kind = TyKind<'tcx>;
|
||||
|
||||
fn kind(self) -> TyKind<'tcx> {
|
||||
|
@ -981,7 +981,7 @@ pub struct Placeholder<T> {
|
|||
|
||||
pub type PlaceholderRegion = Placeholder<BoundRegion>;
|
||||
|
||||
impl PlaceholderLike for PlaceholderRegion {
|
||||
impl rustc_type_ir::inherent::PlaceholderLike for PlaceholderRegion {
|
||||
fn universe(self) -> UniverseIndex {
|
||||
self.universe
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ impl PlaceholderLike for PlaceholderRegion {
|
|||
|
||||
pub type PlaceholderType = Placeholder<BoundTy>;
|
||||
|
||||
impl PlaceholderLike for PlaceholderType {
|
||||
impl rustc_type_ir::inherent::PlaceholderLike for PlaceholderType {
|
||||
fn universe(self) -> UniverseIndex {
|
||||
self.universe
|
||||
}
|
||||
|
@ -1028,7 +1028,7 @@ pub struct BoundConst<'tcx> {
|
|||
|
||||
pub type PlaceholderConst = Placeholder<BoundVar>;
|
||||
|
||||
impl PlaceholderLike for PlaceholderConst {
|
||||
impl rustc_type_ir::inherent::PlaceholderLike for PlaceholderConst {
|
||||
fn universe(self) -> UniverseIndex {
|
||||
self.universe
|
||||
}
|
||||
|
|
|
@ -2,19 +2,19 @@ use rustc_data_structures::captures::Captures;
|
|||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
|
||||
use rustc_span::Span;
|
||||
use rustc_type_ir::ClauseKind as IrClauseKind;
|
||||
use rustc_type_ir::PredicateKind as IrPredicateKind;
|
||||
use rustc_type_ir::TraitRef as IrTraitRef;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::ty::visit::TypeVisitableExt;
|
||||
use crate::ty::{
|
||||
self, AliasTy, Binder, DebruijnIndex, DebugWithInfcx, EarlyBinder, GenericArg, GenericArgs,
|
||||
GenericArgsRef, PredicatePolarity, Term, Ty, TyCtxt, TypeFlags, WithCachedTypeInfo,
|
||||
self, AliasTy, Binder, DebruijnIndex, DebugWithInfcx, EarlyBinder, GenericArgsRef,
|
||||
PredicatePolarity, Term, Ty, TyCtxt, TypeFlags, WithCachedTypeInfo,
|
||||
};
|
||||
|
||||
pub type TraitRef<'tcx> = IrTraitRef<TyCtxt<'tcx>>;
|
||||
pub type ClauseKind<'tcx> = IrClauseKind<TyCtxt<'tcx>>;
|
||||
pub type PredicateKind<'tcx> = IrPredicateKind<TyCtxt<'tcx>>;
|
||||
|
||||
|
@ -30,6 +30,8 @@ pub struct Predicate<'tcx>(
|
|||
pub(super) Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
||||
);
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx> {}
|
||||
|
||||
impl<'tcx> rustc_type_ir::visit::Flags for Predicate<'tcx> {
|
||||
fn flags(&self) -> TypeFlags {
|
||||
self.0.flags
|
||||
|
@ -326,76 +328,6 @@ impl<'tcx> ty::List<ty::PolyExistentialPredicate<'tcx>> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A complete reference to a trait. These take numerous guises in syntax,
|
||||
/// but perhaps the most recognizable form is in a where-clause:
|
||||
/// ```ignore (illustrative)
|
||||
/// T: Foo<U>
|
||||
/// ```
|
||||
/// This would be represented by a trait-reference where the `DefId` is the
|
||||
/// `DefId` for the trait `Foo` and the args define `T` as parameter 0,
|
||||
/// and `U` as parameter 1.
|
||||
///
|
||||
/// Trait references also appear in object types like `Foo<U>`, but in
|
||||
/// that case the `Self` parameter is absent from the generic parameters.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||
pub struct TraitRef<'tcx> {
|
||||
pub def_id: DefId,
|
||||
pub args: GenericArgsRef<'tcx>,
|
||||
/// This field exists to prevent the creation of `TraitRef` without
|
||||
/// calling [`TraitRef::new`].
|
||||
pub(super) _use_trait_ref_new_instead: (),
|
||||
}
|
||||
|
||||
impl<'tcx> TraitRef<'tcx> {
|
||||
pub fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
) -> Self {
|
||||
let args = tcx.check_and_mk_args(trait_def_id, args);
|
||||
Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () }
|
||||
}
|
||||
|
||||
pub fn from_lang_item(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_lang_item: LangItem,
|
||||
span: Span,
|
||||
args: impl IntoIterator<Item: Into<ty::GenericArg<'tcx>>>,
|
||||
) -> Self {
|
||||
let trait_def_id = tcx.require_lang_item(trait_lang_item, Some(span));
|
||||
Self::new(tcx, trait_def_id, args)
|
||||
}
|
||||
|
||||
pub fn from_method(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx> {
|
||||
let defs = tcx.generics_of(trait_id);
|
||||
ty::TraitRef::new(tcx, trait_id, tcx.mk_args(&args[..defs.own_params.len()]))
|
||||
}
|
||||
|
||||
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
|
||||
/// are the parameters defined on trait.
|
||||
pub fn identity(tcx: TyCtxt<'tcx>, def_id: DefId) -> TraitRef<'tcx> {
|
||||
ty::TraitRef::new(tcx, def_id, GenericArgs::identity_for_item(tcx, def_id))
|
||||
}
|
||||
|
||||
pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
self.def_id,
|
||||
[self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
|
||||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn self_ty(&self) -> Ty<'tcx> {
|
||||
self.args.type_at(0)
|
||||
}
|
||||
}
|
||||
|
||||
pub type PolyTraitRef<'tcx> = ty::Binder<'tcx, TraitRef<'tcx>>;
|
||||
|
||||
impl<'tcx> PolyTraitRef<'tcx> {
|
||||
|
@ -408,12 +340,6 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagArg for TraitRef<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
/// An existential reference to a trait, where `Self` is erased.
|
||||
/// For example, the trait object `Trait<'a, 'b, X, Y>` is:
|
||||
/// ```ignore (illustrative)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::ty::GenericArg;
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
|
||||
use hir::def::Namespace;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
use rustc_hir as hir;
|
||||
|
@ -11,6 +12,8 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
|||
mod pretty;
|
||||
pub use self::pretty::*;
|
||||
|
||||
use super::Lift;
|
||||
|
||||
pub type PrintError = std::fmt::Error;
|
||||
|
||||
pub trait Print<'tcx, P> {
|
||||
|
@ -334,3 +337,21 @@ pub fn describe_as_module(def_id: impl Into<LocalDefId>, tcx: TyCtxt<'_>) -> Str
|
|||
format!("module `{}`", tcx.def_path_str(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> rustc_type_ir::ir_print::IrPrint<T> for TyCtxt<'_>
|
||||
where
|
||||
T: Copy + for<'a, 'tcx> Lift<TyCtxt<'tcx>, Lifted: Print<'tcx, FmtPrinter<'a, 'tcx>>>,
|
||||
{
|
||||
fn print(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
ty::tls::with(|tcx| {
|
||||
let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
|
||||
tcx.lift(*t).expect("could not lift for printing").print(&mut cx)?;
|
||||
fmt.write_str(&cx.into_buffer())?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn print_debug(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
with_no_trimmed_paths!(Self::print(t, fmt))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
|||
use rustc_hir::def_id::{DefIdMap, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefKey, DefPathDataName};
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_macros::Lift;
|
||||
use rustc_macros::{extension, Lift};
|
||||
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
|
@ -2919,16 +2919,17 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitName<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[extension(pub trait PrintTraitRefExt<'tcx>)]
|
||||
impl<'tcx> ty::TraitRef<'tcx> {
|
||||
pub fn print_only_trait_path(self) -> TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
fn print_only_trait_path(self) -> TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
TraitRefPrintOnlyTraitPath(self)
|
||||
}
|
||||
|
||||
pub fn print_trait_sugared(self) -> TraitRefPrintSugared<'tcx> {
|
||||
fn print_trait_sugared(self) -> TraitRefPrintSugared<'tcx> {
|
||||
TraitRefPrintSugared(self)
|
||||
}
|
||||
|
||||
pub fn print_only_trait_name(self) -> TraitRefPrintOnlyTraitName<'tcx> {
|
||||
fn print_only_trait_name(self) -> TraitRefPrintOnlyTraitName<'tcx> {
|
||||
TraitRefPrintOnlyTraitName(self)
|
||||
}
|
||||
}
|
||||
|
@ -3032,6 +3033,10 @@ forward_display_to_print! {
|
|||
define_print! {
|
||||
(self, cx):
|
||||
|
||||
ty::TraitRef<'tcx> {
|
||||
p!(write("<{} as {}>", self.self_ty(), self.print_only_trait_path()))
|
||||
}
|
||||
|
||||
ty::TypeAndMut<'tcx> {
|
||||
p!(write("{}", self.mutbl.prefix_str()), print(self.ty))
|
||||
}
|
||||
|
@ -3113,10 +3118,6 @@ define_print_and_forward_display! {
|
|||
p!("fn", pretty_fn_sig(self.inputs(), self.c_variadic, self.output()));
|
||||
}
|
||||
|
||||
ty::TraitRef<'tcx> {
|
||||
p!(write("<{} as {}>", self.self_ty(), self.print_only_trait_path()))
|
||||
}
|
||||
|
||||
TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
p!(print_def_path(self.0.def_id, self.0.args));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub type RegionKind<'tcx> = IrRegionKind<TyCtxt<'tcx>>;
|
|||
#[rustc_pass_by_value]
|
||||
pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
|
||||
|
||||
impl<'tcx> rustc_type_ir::IntoKind for Region<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::IntoKind for Region<'tcx> {
|
||||
type Kind = RegionKind<'tcx>;
|
||||
|
||||
fn kind(self) -> RegionKind<'tcx> {
|
||||
|
@ -137,7 +137,7 @@ impl<'tcx> Region<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::new::Region<TyCtxt<'tcx>> for Region<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::Region<TyCtxt<'tcx>> for Region<'tcx> {
|
||||
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
|
||||
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon })
|
||||
}
|
||||
|
|
|
@ -132,12 +132,6 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::FnSig<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
with_no_trimmed_paths!(fmt::Display::fmt(self, f))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::DebugWithInfcx<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
|
||||
this: WithInfcx<'_, Infcx, &Self>,
|
||||
|
@ -478,7 +472,7 @@ TrivialTypeTraversalAndLiftImpls! {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Lift implementations
|
||||
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
|
||||
impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
|
||||
type Lifted = Option<T::Lifted>;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
Some(match self {
|
||||
|
@ -488,7 +482,7 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for Term<'a> {
|
||||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
|
||||
type Lifted = ty::Term<'tcx>;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
Some(
|
||||
|
|
|
@ -942,7 +942,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T> rustc_type_ir::BoundVars<TyCtxt<'tcx>> for ty::Binder<'tcx, T> {
|
||||
impl<'tcx, T> rustc_type_ir::inherent::BoundVars<TyCtxt<'tcx>> for ty::Binder<'tcx, T> {
|
||||
fn bound_vars(&self) -> &'tcx List<ty::BoundVariableKind> {
|
||||
self.bound_vars
|
||||
}
|
||||
|
@ -1812,7 +1812,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::new::Ty<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
impl<'tcx> rustc_type_ir::inherent::Ty<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
|
||||
Ty::new_bound(tcx, debruijn, ty::BoundTy { var, kind: ty::BoundTyKind::Anon })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue