Skip to content

Commit 9783fcc

Browse files
committed
Make folding traits generic over the Interner
1 parent dea342d commit 9783fcc

File tree

39 files changed

+160
-130
lines changed

39 files changed

+160
-130
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ struct RemapLateBound<'a, 'tcx> {
464464
mapping: &'a FxHashMap<ty::BoundRegionKind, ty::BoundRegionKind>,
465465
}
466466

467-
impl<'tcx> TypeFolder<'tcx> for RemapLateBound<'_, 'tcx> {
467+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
468468
fn tcx(&self) -> TyCtxt<'tcx> {
469469
self.tcx
470470
}
@@ -829,7 +829,7 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
829829
}
830830
}
831831

832-
impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
832+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
833833
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
834834
self.ocx.infcx.tcx
835835
}

compiler/rustc_hir_analysis/src/collect/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ fn infer_placeholder_type<'a>(
850850
tcx: TyCtxt<'tcx>,
851851
}
852852

853-
impl<'tcx> TypeFolder<'tcx> for MakeNameable<'tcx> {
853+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for MakeNameable<'tcx> {
854854
fn tcx(&self) -> TyCtxt<'tcx> {
855855
self.tcx
856856
}

compiler/rustc_hir_analysis/src/hir_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ struct EraseAllBoundRegions<'tcx> {
189189
// us an inaccurate span for an error message, but cannot
190190
// lead to unsoundness (we call `delay_span_bug` at the start
191191
// of `diagnostic_hir_wf_check`).
192-
impl<'tcx> TypeFolder<'tcx> for EraseAllBoundRegions<'tcx> {
192+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
193193
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
194194
self.tcx
195195
}

compiler/rustc_hir_typeck/src/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, op: hir::BinOp) -> bool
963963

964964
struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span);
965965

966-
impl<'tcx> TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
966+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TypeParamEraser<'_, 'tcx> {
967967
fn tcx(&self) -> TyCtxt<'tcx> {
968968
self.0.tcx
969969
}

compiler/rustc_hir_typeck/src/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ struct EraseEarlyRegions<'tcx> {
763763
tcx: TyCtxt<'tcx>,
764764
}
765765

766-
impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> {
766+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
767767
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
768768
self.tcx
769769
}
@@ -779,7 +779,7 @@ impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> {
779779
}
780780
}
781781

782-
impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
782+
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
783783
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
784784
self.tcx
785785
}

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ struct Canonicalizer<'cx, 'tcx> {
326326
binder_index: ty::DebruijnIndex,
327327
}
328328

329-
impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
329+
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
330330
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
331331
self.tcx
332332
}

compiler/rustc_infer/src/infer/combine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ struct ConstInferUnifier<'cx, 'tcx> {
844844
target_vid: ty::ConstVid<'tcx>,
845845
}
846846

847-
impl<'tcx> FallibleTypeFolder<'tcx> for ConstInferUnifier<'_, 'tcx> {
847+
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
848848
type Error = TypeError<'tcx>;
849849

850850
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {

compiler/rustc_infer/src/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
105105
}
106106
}
107107

108-
impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
108+
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
109109
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
110110
self.infcx.tcx
111111
}

compiler/rustc_infer/src/infer/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub struct InferenceFudger<'a, 'tcx> {
175175
const_vars: (Range<ConstVid<'tcx>>, Vec<ConstVariableOrigin>),
176176
}
177177

178-
impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> {
178+
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
179179
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
180180
self.infcx.tcx
181181
}

compiler/rustc_infer/src/infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ struct InferenceLiteralEraser<'tcx> {
18521852
tcx: TyCtxt<'tcx>,
18531853
}
18541854

1855-
impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> {
1855+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
18561856
fn tcx(&self) -> TyCtxt<'tcx> {
18571857
self.tcx
18581858
}
@@ -1870,7 +1870,7 @@ struct ShallowResolver<'a, 'tcx> {
18701870
infcx: &'a InferCtxt<'tcx>,
18711871
}
18721872

1873-
impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
1873+
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ShallowResolver<'a, 'tcx> {
18741874
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
18751875
self.infcx.tcx
18761876
}
@@ -2064,7 +2064,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
20642064
idx: u32,
20652065
}
20662066

2067-
impl<'tcx> TypeFolder<'tcx> for ReplaceParamAndInferWithPlaceholder<'tcx> {
2067+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
20682068
fn tcx(&self) -> TyCtxt<'tcx> {
20692069
self.tcx
20702070
}

compiler/rustc_infer/src/infer/resolve.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
3131
}
3232
}
3333

34-
impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
34+
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
3535
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
3636
TypeFolder::tcx(&self.shallow_resolver)
3737
}
@@ -73,7 +73,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
7373
}
7474
}
7575

76-
impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
76+
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
7777
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
7878
self.infcx.tcx
7979
}
@@ -211,7 +211,7 @@ struct FullTypeResolver<'a, 'tcx> {
211211
infcx: &'a InferCtxt<'tcx>,
212212
}
213213

214-
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
214+
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
215215
type Error = FixupError<'tcx>;
216216

217217
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {

compiler/rustc_infer/src/traits/structural_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
6161
///////////////////////////////////////////////////////////////////////////
6262
// TypeFoldable implementations.
6363

64-
impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
64+
impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable<TyCtxt<'tcx>> for traits::Obligation<'tcx, O> {
6565
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
6666
Ok(traits::Obligation {
6767
cause: self.cause,

compiler/rustc_macros/src/type_foldable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
2323
});
2424

2525
s.bound_impl(
26-
quote!(::rustc_middle::ty::fold::ir::TypeFoldable<'tcx>),
26+
quote!(::rustc_middle::ty::fold::ir::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>),
2727
quote! {
2828
fn try_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<'tcx>>(
2929
self,

compiler/rustc_middle/src/infer/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Canonical<'tcx, V> {
4242

4343
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
4444

45-
impl<'tcx> ty::ir::TypeFoldable<'tcx> for CanonicalVarInfos<'tcx> {
45+
impl<'tcx> ty::ir::TypeFoldable<TyCtxt<'tcx>> for CanonicalVarInfos<'tcx> {
4646
fn try_fold_with<F: ty::FallibleTypeFolder<'tcx>>(
4747
self,
4848
folder: &mut F,

compiler/rustc_middle/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ macro_rules! CloneLiftImpls {
6969
macro_rules! TrivialTypeTraversalImpls {
7070
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
7171
$(
72-
impl<$tcx> $crate::ty::fold::ir::TypeFoldable<$tcx> for $ty {
72+
impl<$tcx> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty {
7373
fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
7474
self,
7575
_: &mut F,
@@ -121,7 +121,7 @@ macro_rules! EnumTypeTraversalImpl {
121121
(impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path {
122122
$($variants:tt)*
123123
} $(where $($wc:tt)*)*) => {
124-
impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$tcx> for $s
124+
impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $s
125125
$(where $($wc)*)*
126126
{
127127
fn try_fold_with<V: $crate::ty::fold::FallibleTypeFolder<$tcx>>(

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2742,7 +2742,7 @@ impl UserTypeProjection {
27422742
}
27432743
}
27442744

2745-
impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
2745+
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for UserTypeProjection {
27462746
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
27472747
Ok(UserTypeProjection {
27482748
base: self.base.try_fold_with(folder)?,

compiler/rustc_middle/src/mir/type_foldable.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ TrivialTypeTraversalImpls! {
3030
}
3131
}
3232

33-
impl<'tcx> TypeFoldable<'tcx> for &'tcx [InlineAsmTemplatePiece] {
33+
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [InlineAsmTemplatePiece] {
3434
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
3535
Ok(self)
3636
}
3737
}
3838

39-
impl<'tcx> TypeFoldable<'tcx> for &'tcx [Span] {
39+
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [Span] {
4040
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
4141
Ok(self)
4242
}
4343
}
4444

45-
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
45+
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<PlaceElem<'tcx>> {
4646
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
4747
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v))
4848
}
4949
}
5050

51-
impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
51+
impl<'tcx, R: Idx, C: Idx> TypeFoldable<TyCtxt<'tcx>> for BitMatrix<R, C> {
5252
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
5353
Ok(self)
5454
}

compiler/rustc_middle/src/traits/solve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct ExternalConstraintsData<'tcx> {
2626
pub opaque_types: Vec<(Ty<'tcx>, Ty<'tcx>)>,
2727
}
2828

29-
impl<'tcx> TypeFoldable<'tcx> for ExternalConstraints<'tcx> {
29+
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
3030
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
3131
Ok(ir::FallibleTypeFolder::tcx(folder).intern_external_constraints(
3232
ExternalConstraintsData {

compiler/rustc_middle/src/ty/abstract_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> TyCtxt<'tcx> {
5252
tcx: TyCtxt<'tcx>,
5353
}
5454

55-
impl<'tcx> TypeFolder<'tcx> for Expander<'tcx> {
55+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
5656
fn tcx(&self) -> TyCtxt<'tcx> {
5757
self.tcx
5858
}

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub struct MakeSuggestableFolder<'tcx> {
536536
infer_suggestable: bool,
537537
}
538538

539-
impl<'tcx> FallibleTypeFolder<'tcx> for MakeSuggestableFolder<'tcx> {
539+
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
540540
type Error = ();
541541

542542
fn tcx(&self) -> TyCtxt<'tcx> {

compiler/rustc_middle/src/ty/erase_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct RegionEraserVisitor<'tcx> {
3434
tcx: TyCtxt<'tcx>,
3535
}
3636

37-
impl<'tcx> TypeFolder<'tcx> for RegionEraserVisitor<'tcx> {
37+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
3838
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
3939
self.tcx
4040
}

0 commit comments

Comments
 (0)