Skip to content

Commit a3c9eed

Browse files
committed
Auto merge of rust-lang#107924 - eggyal:move_fold_visit_traits_to_type_lib_with_trait_alias, r=oli-obk
Move folding & visiting traits into type library This is a rework of rust-lang#107712, following feedback on that PR. In particular, this version uses trait aliases to reduce the API churn for trait consumers. Doing so requires a workaround for rust-lang#107747 until its fix in rust-lang#107803 is merged into the stage0 compiler; this workaround, which uses conditional compilation based on the `bootstrap` configuration predicate, sits in dedicated commit b409329 for ease of reversion. The possibility of the `rustc_middle` crate retaining its own distinct versions of each folding/visiting trait, blanket-implemented on all types that implement the respective trait in the type library, was also explored: however since this would necessitate making each `rustc_middle` trait a subtrait of the respective type library trait (so that such blanket implementations can delegate their generic methods), no benefit would be gained. r? types
2 parents 0b439b1 + 63ad5d0 commit a3c9eed

File tree

86 files changed

+1182
-999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1182
-999
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::mir::{
1717
};
1818
use rustc_middle::traits::ObligationCause;
1919
use rustc_middle::traits::ObligationCauseCode;
20-
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitable};
20+
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable};
2121
use rustc_span::Span;
2222

2323
use crate::{

compiler/rustc_codegen_cranelift/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mod prelude {
8686
pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout};
8787
pub(crate) use rustc_middle::ty::{
8888
self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut,
89-
TypeFoldable, TypeVisitable, UintTy,
89+
TypeFoldable, UintTy,
9090
};
9191
pub(crate) use rustc_target::abi::{Abi, Scalar, Size, VariantIdx};
9292

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::*;
33
use rustc_middle::mir;
44
use rustc_middle::mir::interpret::ErrorHandled;
55
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
6-
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable, TypeVisitable};
6+
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
77
use rustc_target::abi::call::{FnAbi, PassMode};
88

99
use std::iter;

compiler/rustc_const_eval/src/interpret/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_middle::mir::interpret::InterpResult;
2-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
2+
use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
33
use std::ops::ControlFlow;
44

55
/// Checks whether a type contains generic parameters which require substitution.
@@ -21,7 +21,7 @@ where
2121
tcx: TyCtxt<'tcx>,
2222
}
2323

24-
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
24+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedSubstVisitor<'tcx> {
2525
type BreakTy = FoundParam;
2626

2727
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {

compiler/rustc_hir_analysis/src/check/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
261261
selftys: Vec<(Span, Option<String>)>,
262262
}
263263

264-
impl<'tcx> ty::visit::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
264+
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for ProhibitOpaqueVisitor<'tcx> {
265265
type BreakTy = Ty<'tcx>;
266266

267267
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
@@ -1447,7 +1447,7 @@ fn opaque_type_cycle_error(
14471447
opaques: Vec<DefId>,
14481448
closures: Vec<DefId>,
14491449
}
1450-
impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
1450+
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector {
14511451
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
14521452
match *t.kind() {
14531453
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_infer::traits::util;
1616
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1717
use rustc_middle::ty::util::ExplicitSelf;
1818
use rustc_middle::ty::{
19-
self, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable,
19+
self, ir::TypeFolder, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeSuperFoldable,
2020
};
2121
use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt};
2222
use rustc_span::Span;
@@ -464,8 +464,8 @@ struct RemapLateBound<'a, 'tcx> {
464464
mapping: &'a FxHashMap<ty::BoundRegionKind, ty::BoundRegionKind>,
465465
}
466466

467-
impl<'tcx> TypeFolder<'tcx> for RemapLateBound<'_, 'tcx> {
468-
fn tcx(&self) -> TyCtxt<'tcx> {
467+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
468+
fn interner(&self) -> TyCtxt<'tcx> {
469469
self.tcx
470470
}
471471

@@ -829,14 +829,14 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
829829
}
830830
}
831831

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

837837
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
838838
if let ty::Alias(ty::Projection, proj) = ty.kind()
839-
&& self.tcx().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
839+
&& self.interner().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
840840
{
841841
if let Some((ty, _)) = self.types.get(&proj.def_id) {
842842
return *ty;
@@ -852,7 +852,7 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
852852
});
853853
self.types.insert(proj.def_id, (infer_ty, proj.substs));
854854
// Recurse into bounds
855-
for (pred, pred_span) in self.tcx().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.tcx(), proj.substs) {
855+
for (pred, pred_span) in self.interner().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.interner(), proj.substs) {
856856
let pred = pred.fold_with(self);
857857
let pred = self.ocx.normalize(
858858
&ObligationCause::misc(self.span, self.body_id),
@@ -861,7 +861,7 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
861861
);
862862

863863
self.ocx.register_obligation(traits::Obligation::new(
864-
self.tcx(),
864+
self.interner(),
865865
ObligationCause::new(
866866
self.span,
867867
self.body_id,

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use rustc_middle::mir::ConstraintCategory;
1616
use rustc_middle::ty::query::Providers;
1717
use rustc_middle::ty::trait_def::TraitSpecializationKind;
1818
use rustc_middle::ty::{
19-
self, AdtKind, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable,
20-
TypeVisitable, TypeVisitor,
19+
self, ir::TypeVisitor, AdtKind, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable,
20+
TypeSuperVisitable,
2121
};
2222
use rustc_middle::ty::{GenericArgKind, InternalSubsts};
2323
use rustc_session::parse::feature_err;
@@ -772,7 +772,7 @@ impl<'tcx> GATSubstCollector<'tcx> {
772772
}
773773
}
774774

775-
impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
775+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATSubstCollector<'tcx> {
776776
type BreakTy = !;
777777

778778
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
@@ -1435,7 +1435,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14351435
struct CountParams {
14361436
params: FxHashSet<u32>,
14371437
}
1438-
impl<'tcx> ty::visit::TypeVisitor<'tcx> for CountParams {
1438+
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for CountParams {
14391439
type BreakTy = ();
14401440

14411441
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir as hir;
88
use rustc_middle::ty::subst::InternalSubsts;
99
use rustc_middle::ty::util::IgnoreRegions;
1010
use rustc_middle::ty::{
11-
self, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
11+
self, ir::TypeVisitor, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
1212
};
1313
use rustc_session::lint;
1414
use rustc_span::def_id::{DefId, LocalDefId};
@@ -552,7 +552,7 @@ fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty:
552552
seen: FxHashSet<DefId>,
553553
}
554554

555-
impl<'tcx> TypeVisitor<'tcx> for DisableAutoTraitVisitor<'tcx> {
555+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for DisableAutoTraitVisitor<'tcx> {
556556
type BreakTy = ();
557557
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
558558
let tcx = self.tcx;

compiler/rustc_hir_analysis/src/collect/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeNa
1717
use rustc_middle::bug;
1818
use rustc_middle::hir::nested_filter;
1919
use rustc_middle::middle::resolve_lifetime::*;
20-
use rustc_middle::ty::{self, DefIdTree, TyCtxt, TypeSuperVisitable, TypeVisitor};
20+
use rustc_middle::ty::{self, ir::TypeVisitor, DefIdTree, TyCtxt, TypeSuperVisitable};
2121
use rustc_span::def_id::DefId;
2222
use rustc_span::symbol::{sym, Ident};
2323
use rustc_span::Span;
@@ -1752,7 +1752,7 @@ fn is_late_bound_map(
17521752

17531753
use std::ops::ControlFlow;
17541754
use ty::Ty;
1755-
impl<'tcx> TypeVisitor<'tcx> for ConstrainedCollectorPostAstConv {
1755+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ConstrainedCollectorPostAstConv {
17561756
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<!> {
17571757
match t.kind() {
17581758
ty::Param(param_ty) => {

compiler/rustc_hir_analysis/src/collect/type_of.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths;
99
use rustc_middle::ty::subst::InternalSubsts;
1010
use rustc_middle::ty::util::IntTypeExt;
1111
use rustc_middle::ty::{
12-
self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitable,
12+
self, ir::TypeFolder, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeSuperFoldable, TypeVisitable,
1313
};
1414
use rustc_span::symbol::Ident;
1515
use rustc_span::{Span, DUMMY_SP};
@@ -850,8 +850,8 @@ fn infer_placeholder_type<'a>(
850850
tcx: TyCtxt<'tcx>,
851851
}
852852

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

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_data_structures::fx::FxHashSet;
2-
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
2+
use rustc_middle::ty::visit::{ir::TypeVisitor, TypeSuperVisitable, TypeVisitable};
33
use rustc_middle::ty::{self, Ty, TyCtxt};
44
use rustc_span::source_map::Span;
55
use std::ops::ControlFlow;
@@ -56,7 +56,7 @@ struct ParameterCollector {
5656
include_nonconstraining: bool,
5757
}
5858

59-
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
59+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
6060
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
6161
match *t.kind() {
6262
ty::Alias(ty::Projection, ..) if !self.include_nonconstraining => {

compiler/rustc_hir_analysis/src/hir_wf_check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{ForeignItem, ForeignItemKind};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_infer::traits::{ObligationCause, WellFormedLoc};
77
use rustc_middle::ty::query::Providers;
8-
use rustc_middle::ty::{self, Region, TyCtxt, TypeFoldable, TypeFolder};
8+
use rustc_middle::ty::{self, ir::TypeFolder, Region, TyCtxt, TypeFoldable};
99
use rustc_span::def_id::LocalDefId;
1010
use rustc_trait_selection::traits;
1111

@@ -189,8 +189,8 @@ 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> {
193-
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
192+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
193+
fn interner(&self) -> TyCtxt<'tcx> {
194194
self.tcx
195195
}
196196
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {

compiler/rustc_hir_analysis/src/variance/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ use rustc_arena::DroplessArena;
77
use rustc_hir::def::DefKind;
88
use rustc_hir::def_id::{DefId, LocalDefId};
99
use rustc_middle::ty::query::Providers;
10+
#[cfg(not(bootstrap))]
11+
use rustc_middle::ty::TypeVisitable;
1012
use rustc_middle::ty::{self, CrateVariancesMap, SubstsRef, Ty, TyCtxt};
11-
use rustc_middle::ty::{DefIdTree, TypeSuperVisitable, TypeVisitable};
13+
use rustc_middle::ty::{DefIdTree, TypeSuperVisitable};
1214
use std::ops::ControlFlow;
1315

1416
/// Defines the `TermsContext` basically houses an arena where we can
@@ -99,7 +101,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
99101
}
100102
}
101103

102-
impl<'tcx> ty::TypeVisitor<'tcx> for OpaqueTypeLifetimeCollector<'tcx> {
104+
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeLifetimeCollector<'tcx> {
103105
#[instrument(level = "trace", skip(self), ret)]
104106
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
105107
if let ty::RegionKind::ReEarlyBound(ebr) = r.kind() {

compiler/rustc_hir_typeck/src/closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_infer::infer::{InferOk, InferResult};
1212
use rustc_macros::{TypeFoldable, TypeVisitable};
1313
use rustc_middle::ty::subst::InternalSubsts;
1414
use rustc_middle::ty::visit::TypeVisitable;
15-
use rustc_middle::ty::{self, Ty, TypeSuperVisitable, TypeVisitor};
15+
use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeSuperVisitable};
1616
use rustc_span::def_id::LocalDefId;
1717
use rustc_span::source_map::Span;
1818
use rustc_span::sym;
@@ -232,7 +232,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
232232
struct MentionsTy<'tcx> {
233233
expected_ty: Ty<'tcx>,
234234
}
235-
impl<'tcx> TypeVisitor<'tcx> for MentionsTy<'tcx> {
235+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MentionsTy<'tcx> {
236236
type BreakTy = ();
237237

238238
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use rustc_hir as hir;
33
use rustc_hir::def::Res;
44
use rustc_hir::def_id::DefId;
55
use rustc_infer::traits::ObligationCauseCode;
6-
use rustc_middle::ty::{self, DefIdTree, Ty, TypeSuperVisitable, TypeVisitable, TypeVisitor};
6+
use rustc_middle::ty::{
7+
self, ir::TypeVisitor, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
8+
};
79
use rustc_span::{self, Span};
810
use rustc_trait_selection::traits;
911

@@ -247,7 +249,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
247249
t: T,
248250
) -> Option<ty::GenericArg<'tcx>> {
249251
struct FindAmbiguousParameter<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, DefId);
250-
impl<'tcx> TypeVisitor<'tcx> for FindAmbiguousParameter<'_, 'tcx> {
252+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for FindAmbiguousParameter<'_, 'tcx> {
251253
type BreakTy = ty::GenericArg<'tcx>;
252254
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
253255
if let Some(origin) = self.0.type_var_origin(ty)

compiler/rustc_hir_typeck/src/mem_categorization.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
use rustc_middle::hir::place::*;
5252
use rustc_middle::ty::adjustment;
5353
use rustc_middle::ty::fold::TypeFoldable;
54-
use rustc_middle::ty::visit::TypeVisitable;
5554
use rustc_middle::ty::{self, Ty, TyCtxt};
5655

5756
use rustc_data_structures::fx::FxIndexMap;

compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
2020
use rustc_middle::ty::AssocItem;
2121
use rustc_middle::ty::GenericParamDefKind;
2222
use rustc_middle::ty::ToPredicate;
23-
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFoldable, TypeVisitable};
23+
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFoldable};
2424
use rustc_middle::ty::{InternalSubsts, SubstsRef};
2525
use rustc_session::lint;
2626
use rustc_span::def_id::DefId;

compiler/rustc_hir_typeck/src/op.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::ty::adjustment::{
1313
};
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
1515
use rustc_middle::ty::{
16-
self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitable,
16+
self, ir::TypeFolder, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeSuperFoldable, TypeVisitable,
1717
};
1818
use rustc_session::errors::ExprParenthesesNeeded;
1919
use rustc_span::source_map::Spanned;
@@ -963,8 +963,8 @@ 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> {
967-
fn tcx(&self) -> TyCtxt<'tcx> {
966+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TypeParamEraser<'_, 'tcx> {
967+
fn interner(&self) -> TyCtxt<'tcx> {
968968
self.0.tcx
969969
}
970970

compiler/rustc_hir_typeck/src/writeback.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use rustc_infer::infer::InferCtxt;
1313
use rustc_middle::hir::place::Place as HirPlace;
1414
use rustc_middle::mir::FakeReadCause;
1515
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast};
16-
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
17-
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable};
16+
use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable};
17+
use rustc_middle::ty::visit::TypeSuperVisitable;
1818
use rustc_middle::ty::TypeckResults;
1919
use rustc_middle::ty::{self, ClosureSizeProfileData, Ty, TyCtxt};
2020
use rustc_span::symbol::sym;
@@ -561,7 +561,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
561561
struct RecursionChecker {
562562
def_id: LocalDefId,
563563
}
564-
impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
564+
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for RecursionChecker {
565565
type BreakTy = ();
566566
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
567567
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *t.kind() {
@@ -763,8 +763,8 @@ struct EraseEarlyRegions<'tcx> {
763763
tcx: TyCtxt<'tcx>,
764764
}
765765

766-
impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> {
767-
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
766+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
767+
fn interner(&self) -> TyCtxt<'tcx> {
768768
self.tcx
769769
}
770770
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
@@ -779,8 +779,8 @@ impl<'tcx> TypeFolder<'tcx> for EraseEarlyRegions<'tcx> {
779779
}
780780
}
781781

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

@@ -797,7 +797,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
797797
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
798798
let e = self.report_error(t);
799799
self.replaced_with_error = Some(e);
800-
self.tcx().ty_error_with_guaranteed(e)
800+
self.interner().ty_error_with_guaranteed(e)
801801
}
802802
}
803803
}
@@ -814,7 +814,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
814814
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
815815
let e = self.report_error(ct);
816816
self.replaced_with_error = Some(e);
817-
self.tcx().const_error_with_guaranteed(ct.ty(), e)
817+
self.interner().const_error_with_guaranteed(ct.ty(), e)
818818
}
819819
}
820820
}

0 commit comments

Comments
 (0)