diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 7a32cfb10857..66463efd287d 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -121,8 +121,8 @@ impl fmt::Debug for List { } } impl<'tcx, T: super::DebugWithInfcx>> super::DebugWithInfcx> for List { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.map(|this| this.as_slice()), f) diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 012bb7494128..0fedc0e3cf8d 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -93,8 +93,8 @@ impl<'tcx> fmt::Debug for ty::FnSig<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::FnSig<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { let sig = this.data; @@ -149,8 +149,8 @@ impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> { } impl<'tcx> ty::DebugWithInfcx> for Ty<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { this.data.fmt(f) @@ -242,8 +242,8 @@ impl<'tcx> fmt::Debug for AliasTy<'tcx> { } } impl<'tcx> DebugWithInfcx> for AliasTy<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("AliasTy") @@ -263,8 +263,8 @@ impl<'tcx> fmt::Debug for ty::InferConst<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::InferConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ty::InferConst::*; @@ -287,8 +287,8 @@ impl<'tcx> fmt::Debug for ty::consts::Expr<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::consts::Expr<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -320,8 +320,8 @@ impl<'tcx> fmt::Debug for ty::UnevaluatedConst<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::UnevaluatedConst<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_struct("UnevaluatedConst") @@ -337,8 +337,8 @@ impl<'tcx> fmt::Debug for ty::Const<'tcx> { } } impl<'tcx> DebugWithInfcx> for ty::Const<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { // If this is a value, we spend some effort to make it look nice. @@ -395,8 +395,8 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> { } } impl<'tcx> DebugWithInfcx> for GenericArg<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data.unpack() { @@ -413,8 +413,8 @@ impl<'tcx> fmt::Debug for Region<'tcx> { } } impl<'tcx> DebugWithInfcx> for Region<'tcx> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { write!(f, "{:?}", &this.map(|data| data.kind())) @@ -422,8 +422,8 @@ impl<'tcx> DebugWithInfcx> for Region<'tcx> { } impl<'tcx> DebugWithInfcx> for ty::RegionVid { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.infcx.and_then(|infcx| infcx.universe_of_lt(*this.data)) { @@ -434,8 +434,8 @@ impl<'tcx> DebugWithInfcx> for ty::RegionVid { } impl<'tcx, T: DebugWithInfcx>> DebugWithInfcx> for ty::Binder<'tcx, T> { - fn fmt>>( - this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { f.debug_tuple("Binder") diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 46aa5d950cb1..e76f256fdaac 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -683,8 +683,8 @@ pub enum ExistentialPredicate<'tcx> { } impl<'tcx> DebugWithInfcx> for ExistentialPredicate<'tcx> { - fn fmt>>( - this: rustc_type_ir::OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>, + fn fmt>>( + this: rustc_type_ir::OptWithInfcx<'_, TyCtxt<'tcx>, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { fmt::Debug::fmt(&this.data, f) diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index f84841c9f645..8139aacd8658 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -231,13 +231,13 @@ impl Clone for ConstKind { impl fmt::Debug for ConstKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } impl DebugWithInfcx for ConstKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { use ConstKind::*; diff --git a/compiler/rustc_type_ir/src/debug.rs b/compiler/rustc_type_ir/src/debug.rs index 7c6a78469007..556576eef00c 100644 --- a/compiler/rustc_type_ir/src/debug.rs +++ b/compiler/rustc_type_ir/src/debug.rs @@ -26,15 +26,15 @@ impl InferCtxtLike for core::convert::Infallible { } pub trait DebugWithInfcx: fmt::Debug { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result; } impl + ?Sized> DebugWithInfcx for &'_ T { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { >::fmt(this.map(|&data| data), f) @@ -42,8 +42,8 @@ impl + ?Sized> DebugWithInfcx for &'_ T { } impl> DebugWithInfcx for [T] { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { match f.alternate() { @@ -70,46 +70,46 @@ impl> DebugWithInfcx for [T] { } } -pub struct OptWithInfcx<'a, I: Interner, InfCtx: InferCtxtLike, T> { +pub struct OptWithInfcx<'a, I: Interner, Infcx: InferCtxtLike, T> { pub data: T, - pub infcx: Option<&'a InfCtx>, + pub infcx: Option<&'a Infcx>, _interner: PhantomData, } -impl, T: Copy> Copy for OptWithInfcx<'_, I, InfCtx, T> {} +impl, T: Copy> Copy for OptWithInfcx<'_, I, Infcx, T> {} -impl, T: Clone> Clone for OptWithInfcx<'_, I, InfCtx, T> { +impl, T: Clone> Clone for OptWithInfcx<'_, I, Infcx, T> { fn clone(&self) -> Self { Self { data: self.data.clone(), infcx: self.infcx, _interner: self._interner } } } impl<'a, I: Interner, T> OptWithInfcx<'a, I, core::convert::Infallible, T> { - pub fn new_no_ctx(data: T) -> Self { + pub fn with_no_infcx(data: T) -> Self { Self { data, infcx: None, _interner: PhantomData } } } -impl<'a, I: Interner, InfCtx: InferCtxtLike, T> OptWithInfcx<'a, I, InfCtx, T> { - pub fn new(data: T, infcx: &'a InfCtx) -> Self { +impl<'a, I: Interner, Infcx: InferCtxtLike, T> OptWithInfcx<'a, I, Infcx, T> { + pub fn new(data: T, infcx: &'a Infcx) -> Self { Self { data, infcx: Some(infcx), _interner: PhantomData } } - pub fn wrap(self, u: U) -> OptWithInfcx<'a, I, InfCtx, U> { + pub fn wrap(self, u: U) -> OptWithInfcx<'a, I, Infcx, U> { OptWithInfcx { data: u, infcx: self.infcx, _interner: PhantomData } } - pub fn map(self, f: impl FnOnce(T) -> U) -> OptWithInfcx<'a, I, InfCtx, U> { + pub fn map(self, f: impl FnOnce(T) -> U) -> OptWithInfcx<'a, I, Infcx, U> { OptWithInfcx { data: f(self.data), infcx: self.infcx, _interner: PhantomData } } - pub fn as_ref(&self) -> OptWithInfcx<'a, I, InfCtx, &T> { + pub fn as_ref(&self) -> OptWithInfcx<'a, I, Infcx, &T> { OptWithInfcx { data: &self.data, infcx: self.infcx, _interner: PhantomData } } } -impl, T: DebugWithInfcx> fmt::Debug - for OptWithInfcx<'_, I, InfCtx, T> +impl, T: DebugWithInfcx> fmt::Debug + for OptWithInfcx<'_, I, Infcx, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DebugWithInfcx::fmt(self.as_ref(), f) diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index 0006eec4d300..18b31949285d 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -274,8 +274,8 @@ impl hash::Hash for RegionKind { } impl DebugWithInfcx for RegionKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result { match this.data { @@ -301,7 +301,7 @@ impl DebugWithInfcx for RegionKind { } impl fmt::Debug for RegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 91bfce9a142f..3f7171a816b0 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -534,8 +534,8 @@ impl hash::Hash for TyKind { } impl DebugWithInfcx for TyKind { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut core::fmt::Formatter<'_>, ) -> fmt::Result { match this.data { @@ -617,7 +617,7 @@ impl DebugWithInfcx for TyKind { // This is manually implemented because a derive would require `I: Debug` impl fmt::Debug for TyKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - OptWithInfcx::new_no_ctx(self).fmt(f) + OptWithInfcx::with_no_infcx(self).fmt(f) } } @@ -1239,8 +1239,8 @@ impl fmt::Debug for InferTy { } impl> DebugWithInfcx for InferTy { - fn fmt>( - this: OptWithInfcx<'_, I, InfCtx, &Self>, + fn fmt>( + this: OptWithInfcx<'_, I, Infcx, &Self>, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { use InferTy::*;