diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index cdc3216e26c..2b23a076571 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -464,7 +464,7 @@ struct RemapLateBound<'a, 'tcx> { mapping: &'a FxHashMap, } -impl<'tcx> TypeFolder<'tcx> for RemapLateBound<'_, 'tcx> { +impl<'tcx> TypeFolder> for RemapLateBound<'_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -829,7 +829,7 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> { +impl<'tcx> TypeFolder> for ImplTraitInTraitCollector<'_, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.ocx.infcx.tcx } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 5741d9db31d..0c6cdc35b92 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -850,7 +850,7 @@ fn infer_placeholder_type<'a>( tcx: TyCtxt<'tcx>, } - impl<'tcx> TypeFolder<'tcx> for MakeNameable<'tcx> { + impl<'tcx> TypeFolder> for MakeNameable<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index cb9499712e4..a27f6cc2a80 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -189,7 +189,7 @@ struct EraseAllBoundRegions<'tcx> { // us an inaccurate span for an error message, but cannot // lead to unsoundness (we call `delay_span_bug` at the start // of `diagnostic_hir_wf_check`). -impl<'tcx> TypeFolder<'tcx> for EraseAllBoundRegions<'tcx> { +impl<'tcx> TypeFolder> for EraseAllBoundRegions<'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index ffaf58cd7b6..83afbcfad1f 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -963,7 +963,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, op: hir::BinOp) -> bool struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span); -impl<'tcx> TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> { +impl<'tcx> TypeFolder> for TypeParamEraser<'_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.0.tcx } diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 5ce416cac5c..caa75ef2112 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -763,7 +763,7 @@ struct EraseEarlyRegions<'tcx> { tcx: TyCtxt<'tcx>, } -impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> { +impl<'tcx> TypeFolder> for EraseEarlyRegions<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -779,7 +779,7 @@ impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> { } } -impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { +impl<'cx, 'tcx> TypeFolder> for Resolver<'cx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index b0d1d158a3c..2895d477ce5 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -326,7 +326,7 @@ struct Canonicalizer<'cx, 'tcx> { binder_index: ty::DebruijnIndex, } -impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { +impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index b1dfc23f02e..4e0a09baf13 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -844,7 +844,7 @@ struct ConstInferUnifier<'cx, 'tcx> { target_vid: ty::ConstVid<'tcx>, } -impl<'tcx> FallibleTypeFolder<'tcx> for ConstInferUnifier<'_, 'tcx> { +impl<'tcx> FallibleTypeFolder> for ConstInferUnifier<'_, 'tcx> { type Error = TypeError<'tcx>; fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index 37da037f916..9b9f34175e5 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> { } } -impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for TypeFreshener<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/compiler/rustc_infer/src/infer/fudge.rs b/compiler/rustc_infer/src/infer/fudge.rs index aa126814fb5..3520a0f07b7 100644 --- a/compiler/rustc_infer/src/infer/fudge.rs +++ b/compiler/rustc_infer/src/infer/fudge.rs @@ -175,7 +175,7 @@ pub struct InferenceFudger<'a, 'tcx> { const_vars: (Range>, Vec), } -impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for InferenceFudger<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 6a178801306..23904d90fa3 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1852,7 +1852,7 @@ struct InferenceLiteralEraser<'tcx> { tcx: TyCtxt<'tcx>, } -impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> { +impl<'tcx> TypeFolder> for InferenceLiteralEraser<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -1870,7 +1870,7 @@ struct ShallowResolver<'a, 'tcx> { infcx: &'a InferCtxt<'tcx>, } -impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for ShallowResolver<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -2064,7 +2064,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>( idx: u32, } - impl<'tcx> TypeFolder<'tcx> for ReplaceParamAndInferWithPlaceholder<'tcx> { + impl<'tcx> TypeFolder> for ReplaceParamAndInferWithPlaceholder<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index ad3c9449f08..553c8130c1b 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -31,7 +31,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> { } } -impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for OpportunisticVarResolver<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { TypeFolder::tcx(&self.shallow_resolver) } @@ -73,7 +73,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> { } } -impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for OpportunisticRegionResolver<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -211,7 +211,7 @@ struct FullTypeResolver<'a, 'tcx> { infcx: &'a InferCtxt<'tcx>, } -impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { +impl<'a, 'tcx> FallibleTypeFolder> for FullTypeResolver<'a, 'tcx> { type Error = FixupError<'tcx>; fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_infer/src/traits/structural_impls.rs b/compiler/rustc_infer/src/traits/structural_impls.rs index 7f3162a92a4..95df6cd62b9 100644 --- a/compiler/rustc_infer/src/traits/structural_impls.rs +++ b/compiler/rustc_infer/src/traits/structural_impls.rs @@ -61,7 +61,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> { /////////////////////////////////////////////////////////////////////////// // TypeFoldable implementations. -impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for traits::Obligation<'tcx, O> { +impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable> for traits::Obligation<'tcx, O> { fn try_fold_with>(self, folder: &mut F) -> Result { Ok(traits::Obligation { cause: self.cause, diff --git a/compiler/rustc_macros/src/type_foldable.rs b/compiler/rustc_macros/src/type_foldable.rs index 257b353e17c..95bb27ef4f4 100644 --- a/compiler/rustc_macros/src/type_foldable.rs +++ b/compiler/rustc_macros/src/type_foldable.rs @@ -23,7 +23,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:: }); s.bound_impl( - quote!(::rustc_middle::ty::fold::ir::TypeFoldable<'tcx>), + quote!(::rustc_middle::ty::fold::ir::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>), quote! { fn try_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<'tcx>>( self, diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs index c6d67342cad..ada516aa032 100644 --- a/compiler/rustc_middle/src/infer/canonical.rs +++ b/compiler/rustc_middle/src/infer/canonical.rs @@ -42,7 +42,7 @@ pub struct Canonical<'tcx, V> { pub type CanonicalVarInfos<'tcx> = &'tcx List>; -impl<'tcx> ty::ir::TypeFoldable<'tcx> for CanonicalVarInfos<'tcx> { +impl<'tcx> ty::ir::TypeFoldable> for CanonicalVarInfos<'tcx> { fn try_fold_with>( self, folder: &mut F, diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs index 8e673e458c8..08cf12559d7 100644 --- a/compiler/rustc_middle/src/macros.rs +++ b/compiler/rustc_middle/src/macros.rs @@ -69,7 +69,7 @@ macro_rules! CloneLiftImpls { macro_rules! TrivialTypeTraversalImpls { (for <$tcx:lifetime> { $($ty:ty,)+ }) => { $( - impl<$tcx> $crate::ty::fold::ir::TypeFoldable<$tcx> for $ty { + impl<$tcx> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty { fn try_fold_with>( self, _: &mut F, @@ -121,7 +121,7 @@ macro_rules! EnumTypeTraversalImpl { (impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path { $($variants:tt)* } $(where $($wc:tt)*)*) => { - impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$tcx> for $s + impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $s $(where $($wc)*)* { fn try_fold_with>( diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 334ff3b5b82..e0dfc4bbddc 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2742,7 +2742,7 @@ impl UserTypeProjection { } } -impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection { +impl<'tcx> TypeFoldable> for UserTypeProjection { fn try_fold_with>(self, folder: &mut F) -> Result { Ok(UserTypeProjection { base: self.base.try_fold_with(folder)?, diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index 0705b4cff53..006085c0ef5 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -30,25 +30,25 @@ TrivialTypeTraversalImpls! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx [InlineAsmTemplatePiece] { +impl<'tcx> TypeFoldable> for &'tcx [InlineAsmTemplatePiece] { fn try_fold_with>(self, _folder: &mut F) -> Result { Ok(self) } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx [Span] { +impl<'tcx> TypeFoldable> for &'tcx [Span] { fn try_fold_with>(self, _folder: &mut F) -> Result { Ok(self) } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { +impl<'tcx> TypeFoldable> for &'tcx ty::List> { fn try_fold_with>(self, folder: &mut F) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v)) } } -impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix { +impl<'tcx, R: Idx, C: Idx> TypeFoldable> for BitMatrix { fn try_fold_with>(self, _: &mut F) -> Result { Ok(self) } diff --git a/compiler/rustc_middle/src/traits/solve.rs b/compiler/rustc_middle/src/traits/solve.rs index 512285b8e72..de46a0b46b2 100644 --- a/compiler/rustc_middle/src/traits/solve.rs +++ b/compiler/rustc_middle/src/traits/solve.rs @@ -26,7 +26,7 @@ pub struct ExternalConstraintsData<'tcx> { pub opaque_types: Vec<(Ty<'tcx>, Ty<'tcx>)>, } -impl<'tcx> TypeFoldable<'tcx> for ExternalConstraints<'tcx> { +impl<'tcx> TypeFoldable> for ExternalConstraints<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { Ok(ir::FallibleTypeFolder::tcx(folder).intern_external_constraints( ExternalConstraintsData { diff --git a/compiler/rustc_middle/src/ty/abstract_const.rs b/compiler/rustc_middle/src/ty/abstract_const.rs index 0f4a97d8aed..232fa588fe5 100644 --- a/compiler/rustc_middle/src/ty/abstract_const.rs +++ b/compiler/rustc_middle/src/ty/abstract_const.rs @@ -52,7 +52,7 @@ impl<'tcx> TyCtxt<'tcx> { tcx: TyCtxt<'tcx>, } - impl<'tcx> TypeFolder<'tcx> for Expander<'tcx> { + impl<'tcx> TypeFolder> for Expander<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 6b6ee1c06ee..c848395d887 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -536,7 +536,7 @@ pub struct MakeSuggestableFolder<'tcx> { infer_suggestable: bool, } -impl<'tcx> FallibleTypeFolder<'tcx> for MakeSuggestableFolder<'tcx> { +impl<'tcx> FallibleTypeFolder> for MakeSuggestableFolder<'tcx> { type Error = (); fn tcx(&self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_middle/src/ty/erase_regions.rs b/compiler/rustc_middle/src/ty/erase_regions.rs index 25df0ee5560..4cbbdf4126e 100644 --- a/compiler/rustc_middle/src/ty/erase_regions.rs +++ b/compiler/rustc_middle/src/ty/erase_regions.rs @@ -34,7 +34,7 @@ struct RegionEraserVisitor<'tcx> { tcx: TyCtxt<'tcx>, } -impl<'tcx> TypeFolder<'tcx> for RegionEraserVisitor<'tcx> { +impl<'tcx> TypeFolder> for RegionEraserVisitor<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index cb5e0209f2e..f973c91f10d 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -48,20 +48,20 @@ use rustc_hir::def_id::DefId; use std::collections::BTreeMap; -pub trait TypeFoldable<'tcx> = ir::TypeFoldable<'tcx> + TypeVisitable<'tcx>; -pub trait TypeSuperFoldable<'tcx> = ir::TypeSuperFoldable<'tcx>; -pub trait TypeFolder<'tcx> = ir::TypeFolder<'tcx>; -pub trait FallibleTypeFolder<'tcx> = ir::FallibleTypeFolder<'tcx>; +pub trait TypeFoldable<'tcx> = ir::TypeFoldable> + TypeVisitable<'tcx>; +pub trait TypeSuperFoldable<'tcx> = ir::TypeSuperFoldable>; +pub trait TypeFolder<'tcx> = ir::TypeFolder>; +pub trait FallibleTypeFolder<'tcx> = ir::FallibleTypeFolder>; pub mod ir { - use crate::ty::{self, ir::TypeVisitable, Binder, Ty, TyCtxt}; + use crate::ty::{ir::TypeVisitable, Interner}; /// This trait is implemented for every type that can be folded, /// providing the skeleton of the traversal. /// /// To implement this conveniently, use the derive macro located in /// `rustc_macros`. - pub trait TypeFoldable<'tcx>: TypeVisitable> { + pub trait TypeFoldable: TypeVisitable { /// The entry point for folding. To fold a value `t` with a folder `f` /// call: `t.try_fold_with(f)`. /// @@ -72,28 +72,25 @@ pub mod ir { /// calls a folder method specifically for that type (such as /// `F::try_fold_ty`). This is where control transfers from `TypeFoldable` /// to `TypeFolder`. - fn try_fold_with>( - self, - folder: &mut F, - ) -> Result; + fn try_fold_with>(self, folder: &mut F) -> Result; /// A convenient alternative to `try_fold_with` for use with infallible /// folders. Do not override this method, to ensure coherence with /// `try_fold_with`. - fn fold_with>(self, folder: &mut F) -> Self { + fn fold_with>(self, folder: &mut F) -> Self { self.try_fold_with(folder).into_ok() } } // This trait is implemented for types of interest. - pub trait TypeSuperFoldable<'tcx>: TypeFoldable<'tcx> { + pub trait TypeSuperFoldable: TypeFoldable { /// Provides a default fold for a type of interest. This should only be /// called within `TypeFolder` methods, when a non-custom traversal is /// desired for the value of the type of interest passed to that method. /// For example, in `MyFolder::try_fold_ty(ty)`, it is valid to call /// `ty.try_super_fold_with(self)`, but any other folding should be done /// with `xyz.try_fold_with(self)`. - fn try_super_fold_with>( + fn try_super_fold_with>( self, folder: &mut F, ) -> Result; @@ -101,7 +98,7 @@ pub mod ir { /// A convenient alternative to `try_super_fold_with` for use with /// infallible folders. Do not override this method, to ensure coherence /// with `try_super_fold_with`. - fn super_fold_with>(self, folder: &mut F) -> Self { + fn super_fold_with>(self, folder: &mut F) -> Self { self.try_super_fold_with(folder).into_ok() } } @@ -115,29 +112,42 @@ pub mod ir { /// A blanket implementation of [`FallibleTypeFolder`] will defer to /// the infallible methods of this trait to ensure that the two APIs /// are coherent. - pub trait TypeFolder<'tcx>: FallibleTypeFolder<'tcx, Error = !> { - fn tcx(&self) -> TyCtxt<'tcx>; + pub trait TypeFolder: FallibleTypeFolder { + fn tcx(&self) -> I; - fn fold_binder(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> + fn fold_binder(&mut self, t: I::Binder) -> I::Binder where - T: TypeFoldable<'tcx>, + T: TypeFoldable, + I::Binder: TypeSuperFoldable, { t.super_fold_with(self) } - fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { + fn fold_ty(&mut self, t: I::Ty) -> I::Ty + where + I::Ty: TypeSuperFoldable, + { t.super_fold_with(self) } - fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { + fn fold_region(&mut self, r: I::Region) -> I::Region + where + I::Region: TypeSuperFoldable, + { r.super_fold_with(self) } - fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> { + fn fold_const(&mut self, c: I::Const) -> I::Const + where + I::Const: TypeSuperFoldable, + { c.super_fold_with(self) } - fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> { + fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate + where + I::Predicate: TypeSuperFoldable, + { p.super_fold_with(self) } } @@ -149,73 +159,93 @@ pub mod ir { /// A blanket implementation of this trait (that defers to the relevant /// method of [`TypeFolder`]) is provided for all infallible folders in /// order to ensure the two APIs are coherent. - pub trait FallibleTypeFolder<'tcx>: Sized { + pub trait FallibleTypeFolder: Sized { type Error; - fn tcx<'a>(&'a self) -> TyCtxt<'tcx>; + fn tcx<'a>(&'a self) -> I; - fn try_fold_binder(&mut self, t: Binder<'tcx, T>) -> Result, Self::Error> + fn try_fold_binder(&mut self, t: I::Binder) -> Result, Self::Error> where - T: TypeFoldable<'tcx>, + T: TypeFoldable, + I::Binder: TypeSuperFoldable, { t.try_super_fold_with(self) } - fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { + fn try_fold_ty(&mut self, t: I::Ty) -> Result + where + I::Ty: TypeSuperFoldable, + { t.try_super_fold_with(self) } - fn try_fold_region( - &mut self, - r: ty::Region<'tcx>, - ) -> Result, Self::Error> { + fn try_fold_region(&mut self, r: I::Region) -> Result + where + I::Region: TypeSuperFoldable, + { r.try_super_fold_with(self) } - fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result, Self::Error> { + fn try_fold_const(&mut self, c: I::Const) -> Result + where + I::Const: TypeSuperFoldable, + { c.try_super_fold_with(self) } - fn try_fold_predicate( - &mut self, - p: ty::Predicate<'tcx>, - ) -> Result, Self::Error> { + fn try_fold_predicate(&mut self, p: I::Predicate) -> Result + where + I::Predicate: TypeSuperFoldable, + { p.try_super_fold_with(self) } } // This blanket implementation of the fallible trait for infallible folders // delegates to infallible methods to ensure coherence. - impl<'tcx, F> FallibleTypeFolder<'tcx> for F + impl FallibleTypeFolder for F where - F: TypeFolder<'tcx>, + F: TypeFolder, { type Error = !; - fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { + fn tcx<'a>(&'a self) -> I { TypeFolder::tcx(self) } - fn try_fold_binder(&mut self, t: Binder<'tcx, T>) -> Result, !> + fn try_fold_binder(&mut self, t: I::Binder) -> Result, !> where - T: TypeFoldable<'tcx>, + T: TypeFoldable, + I::Binder: TypeSuperFoldable, { Ok(self.fold_binder(t)) } - fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, !> { + fn try_fold_ty(&mut self, t: I::Ty) -> Result + where + I::Ty: TypeSuperFoldable, + { Ok(self.fold_ty(t)) } - fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result, !> { + fn try_fold_region(&mut self, r: I::Region) -> Result + where + I::Region: TypeSuperFoldable, + { Ok(self.fold_region(r)) } - fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result, !> { + fn try_fold_const(&mut self, c: I::Const) -> Result + where + I::Const: TypeSuperFoldable, + { Ok(self.fold_const(c)) } - fn try_fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> Result, !> { + fn try_fold_predicate(&mut self, p: I::Predicate) -> Result + where + I::Predicate: TypeSuperFoldable, + { Ok(self.fold_predicate(p)) } } @@ -236,7 +266,7 @@ where pub ct_op: H, } -impl<'tcx, F, G, H> ir::TypeFolder<'tcx> for BottomUpFolder<'tcx, F, G, H> +impl<'tcx, F, G, H> ir::TypeFolder> for BottomUpFolder<'tcx, F, G, H> where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, @@ -326,7 +356,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> { } } -impl<'a, 'tcx> ir::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { +impl<'a, 'tcx> ir::TypeFolder> for RegionFolder<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -400,7 +430,7 @@ impl<'tcx, D: BoundVarReplacerDelegate<'tcx>> BoundVarReplacer<'tcx, D> { } } -impl<'tcx, D> ir::TypeFolder<'tcx> for BoundVarReplacer<'tcx, D> +impl<'tcx, D> ir::TypeFolder> for BoundVarReplacer<'tcx, D> where D: BoundVarReplacerDelegate<'tcx>, { @@ -666,7 +696,7 @@ impl<'tcx> Shifter<'tcx> { } } -impl<'tcx> ir::TypeFolder<'tcx> for Shifter<'tcx> { +impl<'tcx> ir::TypeFolder> for Shifter<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 6c2c11aa561..212331f0b02 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -674,7 +674,7 @@ fn polymorphize<'tcx>( tcx: TyCtxt<'tcx>, } - impl<'tcx> ty::ir::TypeFolder<'tcx> for PolymorphizationFolder<'tcx> { + impl<'tcx> ty::ir::TypeFolder> for PolymorphizationFolder<'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e12907467d5..4ed0484438f 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -917,7 +917,7 @@ impl<'a, 'tcx> HashStable> for Term<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for Term<'tcx> { +impl<'tcx> ir::TypeFoldable> for Term<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { Ok(self.unpack().try_fold_with(folder)?.pack()) } @@ -1619,7 +1619,7 @@ impl<'a, 'tcx> HashStable> for ParamEnv<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for ParamEnv<'tcx> { +impl<'tcx> ir::TypeFoldable> for ParamEnv<'tcx> { fn try_fold_with>( self, folder: &mut F, diff --git a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs index 7967534f96a..68e1c3e569f 100644 --- a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs +++ b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs @@ -205,7 +205,7 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> { +impl<'tcx> TypeFolder> for NormalizeAfterErasingRegionsFolder<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -241,7 +241,7 @@ impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> { } } -impl<'tcx> FallibleTypeFolder<'tcx> for TryNormalizeAfterErasingRegionsFolder<'tcx> { +impl<'tcx> FallibleTypeFolder> for TryNormalizeAfterErasingRegionsFolder<'tcx> { type Error = NormalizationError<'tcx>; fn tcx(&self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 16905c2100b..900134fe506 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -93,7 +93,7 @@ impl<'tcx> ReverseMapper<'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> { +impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index cf8009b5c35..8bec9ea1e34 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2221,7 +2221,7 @@ struct RegionFolder<'a, 'tcx> { ), } -impl<'a, 'tcx> ty::ir::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { +impl<'a, 'tcx> ty::ir::TypeFolder> for RegionFolder<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 3e811c303ae..43f045c6335 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -363,7 +363,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { // TypeFoldable implementations. /// AdtDefs are basically the same as a DefId. -impl<'tcx> ir::TypeFoldable<'tcx> for ty::AdtDef<'tcx> { +impl<'tcx> ir::TypeFoldable> for ty::AdtDef<'tcx> { fn try_fold_with>(self, _folder: &mut F) -> Result { Ok(self) } @@ -375,7 +375,7 @@ impl<'tcx> ir::TypeVisitable> for ty::AdtDef<'tcx> { } } -impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for (T, U) { +impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> ir::TypeFoldable> for (T, U) { fn try_fold_with>( self, folder: &mut F, @@ -394,7 +394,7 @@ impl<'tcx, T: TypeVisitable<'tcx>, U: TypeVisitable<'tcx>> ir::TypeVisitable, B: TypeFoldable<'tcx>, C: TypeFoldable<'tcx>> - ir::TypeFoldable<'tcx> for (A, B, C) + ir::TypeFoldable> for (A, B, C) { fn try_fold_with>( self, @@ -444,7 +444,7 @@ EnumTypeTraversalImpl! { } where T: TypeVisitable<'tcx>, E: TypeVisitable<'tcx>, } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Rc { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for Rc { fn try_fold_with>( mut self, folder: &mut F, @@ -490,7 +490,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for Rc { } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Arc { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for Arc { fn try_fold_with>( mut self, folder: &mut F, @@ -536,7 +536,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for Arc { } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Box { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for Box { fn try_fold_with>(self, folder: &mut F) -> Result { self.try_map_id(|value| value.try_fold_with(folder)) } @@ -548,7 +548,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for Box { } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Vec { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for Vec { fn try_fold_with>(self, folder: &mut F) -> Result { self.try_map_id(|t| t.try_fold_with(folder)) } @@ -566,7 +566,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for &[T] { } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Box<[T]> { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for Box<[T]> { fn try_fold_with>(self, folder: &mut F) -> Result { self.try_map_id(|t| t.try_fold_with(folder)) } @@ -578,7 +578,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for Box<[T]> } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for ty::Binder<'tcx, T> { +impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for ty::Binder<'tcx, T> { fn try_fold_with>(self, folder: &mut F) -> Result { folder.try_fold_binder(self) } @@ -590,7 +590,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for ty::Binde } } -impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable<'tcx> for ty::Binder<'tcx, T> { +impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable> for ty::Binder<'tcx, T> { fn try_super_fold_with>( self, folder: &mut F, @@ -605,25 +605,25 @@ impl<'tcx, T: TypeVisitable<'tcx>> TypeSuperVisitable> for ty::Bind } } -impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List> { +impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { fn try_fold_with>(self, folder: &mut F) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v)) } } -impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List> { +impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { fn try_fold_with>(self, folder: &mut F) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.mk_const_list(v.iter())) } } -impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List { +impl<'tcx> ir::TypeFoldable> for &'tcx ty::List { fn try_fold_with>(self, folder: &mut F) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v)) } } -impl<'tcx> ir::TypeFoldable<'tcx> for Ty<'tcx> { +impl<'tcx> ir::TypeFoldable> for Ty<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { folder.try_fold_ty(self) } @@ -635,7 +635,7 @@ impl<'tcx> ir::TypeVisitable> for Ty<'tcx> { } } -impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> { +impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { fn try_super_fold_with>( self, folder: &mut F, @@ -729,7 +729,7 @@ impl<'tcx> TypeSuperVisitable> for Ty<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for ty::Region<'tcx> { +impl<'tcx> ir::TypeFoldable> for ty::Region<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { folder.try_fold_region(self) } @@ -741,7 +741,7 @@ impl<'tcx> ir::TypeVisitable> for ty::Region<'tcx> { } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Region<'tcx> { +impl<'tcx> TypeSuperFoldable> for ty::Region<'tcx> { fn try_super_fold_with>( self, _folder: &mut F, @@ -756,7 +756,7 @@ impl<'tcx> TypeSuperVisitable> for ty::Region<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for ty::Predicate<'tcx> { +impl<'tcx> ir::TypeFoldable> for ty::Predicate<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { folder.try_fold_predicate(self) } @@ -768,7 +768,7 @@ impl<'tcx> ir::TypeVisitable> for ty::Predicate<'tcx> { } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Predicate<'tcx> { +impl<'tcx> TypeSuperFoldable> for ty::Predicate<'tcx> { fn try_super_fold_with>( self, folder: &mut F, @@ -784,13 +784,13 @@ impl<'tcx> TypeSuperVisitable> for ty::Predicate<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List> { +impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { fn try_fold_with>(self, folder: &mut F) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v)) } } -impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> ir::TypeFoldable<'tcx> for IndexVec { +impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> ir::TypeFoldable> for IndexVec { fn try_fold_with>(self, folder: &mut F) -> Result { self.try_map_id(|x| x.try_fold_with(folder)) } @@ -802,7 +802,7 @@ impl<'tcx, T: TypeVisitable<'tcx>, I: Idx> ir::TypeVisitable> for I } } -impl<'tcx> ir::TypeFoldable<'tcx> for ty::Const<'tcx> { +impl<'tcx> ir::TypeFoldable> for ty::Const<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { folder.try_fold_const(self) } @@ -814,7 +814,7 @@ impl<'tcx> ir::TypeVisitable> for ty::Const<'tcx> { } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Const<'tcx> { +impl<'tcx> TypeSuperFoldable> for ty::Const<'tcx> { fn try_super_fold_with>( self, folder: &mut F, @@ -836,7 +836,7 @@ impl<'tcx> TypeSuperVisitable> for ty::Const<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for InferConst<'tcx> { +impl<'tcx> ir::TypeFoldable> for InferConst<'tcx> { fn try_fold_with>(self, _folder: &mut F) -> Result { Ok(self) } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index bb9bec8e648..12cab479cd9 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1149,7 +1149,7 @@ struct SkipBindersAt<'tcx> { index: ty::DebruijnIndex, } -impl<'tcx> FallibleTypeFolder<'tcx> for SkipBindersAt<'tcx> { +impl<'tcx> FallibleTypeFolder> for SkipBindersAt<'tcx> { type Error = (); fn tcx(&self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index e9de6992998..f4ddfc4633c 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -227,7 +227,7 @@ impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for GenericArg<'tcx> { +impl<'tcx> ir::TypeFoldable> for GenericArg<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { match self.unpack() { GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into), @@ -475,7 +475,7 @@ impl<'tcx> InternalSubsts<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for SubstsRef<'tcx> { +impl<'tcx> ir::TypeFoldable> for SubstsRef<'tcx> { fn try_fold_with>(self, folder: &mut F) -> Result { // This code is hot enough that it's worth specializing for the most // common length lists, to avoid the overhead of `SmallVec` creation. @@ -503,7 +503,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for SubstsRef<'tcx> { } } -impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List> { +impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { fn try_fold_with>(self, folder: &mut F) -> Result { // This code is fairly hot, though not as hot as `SubstsRef`. // @@ -553,7 +553,7 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for &'tcx ty: pub struct EarlyBinder(pub T); /// For early binders, you should first call `subst` before using any visitors. -impl<'tcx, T> !ir::TypeFoldable<'tcx> for ty::EarlyBinder {} +impl<'tcx, T> !ir::TypeFoldable> for ty::EarlyBinder {} impl<'tcx, T> !ir::TypeVisitable> for ty::EarlyBinder {} impl EarlyBinder { @@ -776,7 +776,7 @@ struct SubstFolder<'a, 'tcx> { binders_passed: u32, } -impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for SubstFolder<'a, 'tcx> { #[inline] fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 5ce6a211376..46e40e415c0 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -842,7 +842,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> { +impl<'tcx> TypeFolder> for OpaqueTypeExpander<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index b10b35b77d4..51aa42ccd5f 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -859,7 +859,7 @@ pub struct RegionReplacer<'a, 'tcx> { tcx: TyCtxt<'tcx>, } -impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for RegionReplacer<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index c71b0e8574f..a94c7cdeeac 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2674,7 +2674,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { var_map: FxHashMap, Ty<'tcx>>, } - impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> { + impl<'a, 'tcx> TypeFolder> for ParamToVarFolder<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 5b98375cdd8..a497f26c608 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -4081,7 +4081,7 @@ struct ReplaceImplTraitFolder<'tcx> { replace_ty: Ty<'tcx>, } -impl<'tcx> TypeFolder<'tcx> for ReplaceImplTraitFolder<'tcx> { +impl<'tcx> TypeFolder> for ReplaceImplTraitFolder<'tcx> { fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { if let ty::Param(ty::ParamTy { index, .. }) = t.kind() { if self.param.index == *index { diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index b16fb819466..f5852485f55 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -448,7 +448,7 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> { } } -impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { +impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { self.selcx.tcx() } @@ -740,7 +740,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> { +impl<'tcx> TypeFolder> for BoundVarReplacer<'_, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -846,7 +846,7 @@ impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> { +impl<'tcx> TypeFolder> for PlaceholderReplacer<'_, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 149f33472ae..50bf6f5fdb5 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -170,7 +170,7 @@ struct QueryNormalizer<'cx, 'tcx> { universes: Vec>, } -impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { +impl<'cx, 'tcx> FallibleTypeFolder> for QueryNormalizer<'cx, 'tcx> { type Error = NoSolution; fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 5e32b23fdca..f87b1a60786 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -769,7 +769,7 @@ struct ReplaceOpaqueTyFolder<'tcx> { binder_index: ty::DebruijnIndex, } -impl<'tcx> ty::ir::TypeFolder<'tcx> for ReplaceOpaqueTyFolder<'tcx> { +impl<'tcx> ty::ir::TypeFolder> for ReplaceOpaqueTyFolder<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 2f05e258259..416bc764f00 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -1007,7 +1007,7 @@ impl<'a, 'tcx> NamedBoundVarSubstitutor<'a, 'tcx> { } } -impl<'a, 'tcx> TypeFolder<'tcx> for NamedBoundVarSubstitutor<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for NamedBoundVarSubstitutor<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -1063,7 +1063,7 @@ impl<'tcx> ParamsSubstitutor<'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> { +impl<'tcx> TypeFolder> for ParamsSubstitutor<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -1139,7 +1139,7 @@ impl<'tcx> ReverseParamsSubstitutor<'tcx> { } } -impl<'tcx> TypeFolder<'tcx> for ReverseParamsSubstitutor<'tcx> { +impl<'tcx> TypeFolder> for ReverseParamsSubstitutor<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index a302750aa1a..c86971aefbe 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -734,7 +734,7 @@ struct RegionReplacer<'a, 'tcx> { tcx: TyCtxt<'tcx>, } -impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for RegionReplacer<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx }