Skip to content

Commit 216d418

Browse files
TypeVisiting binders no longer requires TypeFolding its interior
1 parent d4d23b2 commit 216d418

File tree

10 files changed

+21
-23
lines changed

10 files changed

+21
-23
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_middle::bug;
1111
use rustc_middle::ty::{
12-
self as ty, IsSuggestable, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable,
13-
TypeVisitableExt, TypeVisitor, Upcast,
12+
self as ty, IsSuggestable, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
13+
TypeVisitor, Upcast,
1414
};
1515
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
1616
use rustc_trait_selection::traits;
@@ -927,7 +927,7 @@ struct GenericParamAndBoundVarCollector<'a, 'tcx> {
927927
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'_, 'tcx> {
928928
type Result = ControlFlow<ErrorGuaranteed>;
929929

930-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
930+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(
931931
&mut self,
932932
binder: &ty::Binder<'tcx, T>,
933933
) -> Self::Result {

compiler/rustc_lint/src/impl_trait_overcaptures.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use rustc_middle::ty::relate::{
1515
Relate, RelateResult, TypeRelation, structurally_relate_consts, structurally_relate_tys,
1616
};
1717
use rustc_middle::ty::{
18-
self, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
19-
TypeVisitor,
18+
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
2019
};
2120
use rustc_middle::{bug, span_bug};
2221
use rustc_session::lint::FutureIncompatibilityReason;
@@ -210,7 +209,7 @@ where
210209
VarFn: FnOnce() -> FxHashMap<DefId, ty::Variance>,
211210
OutlivesFn: FnOnce() -> OutlivesEnvironment<'tcx>,
212211
{
213-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, t: &ty::Binder<'tcx, T>) {
212+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &ty::Binder<'tcx, T>) {
214213
// When we get into a binder, we need to add its own bound vars to the scope.
215214
let mut added = vec![];
216215
for arg in t.bound_vars() {

compiler/rustc_middle/src/ty/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> TyCtxt<'tcx> {
6666
{
6767
type Result = ControlFlow<()>;
6868

69-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
69+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(
7070
&mut self,
7171
t: &Binder<'tcx, T>,
7272
) -> Self::Result {
@@ -168,7 +168,7 @@ impl LateBoundRegionsCollector {
168168
}
169169

170170
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for LateBoundRegionsCollector {
171-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) {
171+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) {
172172
self.current_index.shift_in(1);
173173
t.super_visit_with(self);
174174
self.current_index.shift_out(1);

compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ where
10391039
{
10401040
type Result = ControlFlow<Result<(), NoSolution>>;
10411041

1042-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
1042+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
10431043
self.universes.push(None);
10441044
t.super_visit_with(self)?;
10451045
self.universes.pop();

compiler/rustc_trait_selection/src/traits/query/normalize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_macros::extension;
99
pub use rustc_middle::traits::query::NormalizationResult;
1010
use rustc_middle::ty::{
1111
self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable,
12-
TypeVisitableExt, TypeVisitor, TypingMode,
12+
TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
1313
};
1414
use rustc_span::DUMMY_SP;
1515
use tracing::{debug, info, instrument};
@@ -127,7 +127,7 @@ struct MaxEscapingBoundVarVisitor {
127127
}
128128

129129
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
130-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, t: &ty::Binder<'tcx, T>) {
130+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &ty::Binder<'tcx, T>) {
131131
self.outer_index.shift_in(1);
132132
t.super_visit_with(self);
133133
self.outer_index.shift_out(1);

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use rustc_infer::infer::TyCtxtInferExt;
77
use rustc_middle::bug;
88
use rustc_middle::query::Providers;
99
use rustc_middle::ty::{
10-
self, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitor, Upcast,
11-
fold_regions,
10+
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Upcast, fold_regions,
1211
};
1312
use rustc_span::DUMMY_SP;
1413
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
@@ -186,7 +185,7 @@ struct ImplTraitInTraitFinder<'a, 'tcx> {
186185
}
187186

188187
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
189-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, binder: &ty::Binder<'tcx, T>) {
188+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, binder: &ty::Binder<'tcx, T>) {
190189
self.depth.shift_in(1);
191190
binder.super_visit_with(self);
192191
self.depth.shift_out(1);

compiler/rustc_type_ir/src/binder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Binder<I, T> {
128128
}
129129
}
130130

131-
impl<I: Interner, T: TypeFoldable<I>> TypeVisitable<I> for Binder<I, T> {
131+
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Binder<I, T> {
132132
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result {
133133
visitor.visit_binder(self)
134134
}
@@ -147,7 +147,7 @@ impl<I: Interner, T: TypeFoldable<I>> TypeSuperFoldable<I> for Binder<I, T> {
147147
}
148148
}
149149

150-
impl<I: Interner, T: TypeFoldable<I>> TypeSuperVisitable<I> for Binder<I, T> {
150+
impl<I: Interner, T: TypeVisitable<I>> TypeSuperVisitable<I> for Binder<I, T> {
151151
fn super_visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result {
152152
self.as_ref().skip_binder().visit_with(visitor)
153153
}
@@ -292,7 +292,7 @@ impl<I: Interner> ValidateBoundVars<I> {
292292
impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> {
293293
type Result = ControlFlow<()>;
294294

295-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &Binder<I, T>) -> Self::Result {
295+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &Binder<I, T>) -> Self::Result {
296296
self.binder_index.shift_in(1);
297297
let result = t.super_visit_with(self);
298298
self.binder_index.shift_out(1);

compiler/rustc_type_ir/src/ty_kind/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct HasRegionsBoundAt {
342342
// FIXME: Could be optimized to not walk into components with no escaping bound vars.
343343
impl<I: Interner> TypeVisitor<I> for HasRegionsBoundAt {
344344
type Result = ControlFlow<()>;
345-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
345+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
346346
self.binder.shift_in(1);
347347
t.super_visit_with(self)?;
348348
self.binder.shift_out(1);

compiler/rustc_type_ir/src/visit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use smallvec::SmallVec;
5252
use thin_vec::ThinVec;
5353

5454
use crate::inherent::*;
55-
use crate::{self as ty, Interner, TypeFlags, TypeFoldable};
55+
use crate::{self as ty, Interner, TypeFlags};
5656

5757
/// This trait is implemented for every type that can be visited,
5858
/// providing the skeleton of the traversal.
@@ -94,7 +94,7 @@ pub trait TypeVisitor<I: Interner>: Sized {
9494
#[cfg(not(feature = "nightly"))]
9595
type Result: VisitorResult;
9696

97-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
97+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
9898
t.super_visit_with(self)
9999
}
100100

@@ -401,7 +401,7 @@ impl std::fmt::Debug for HasTypeFlagsVisitor {
401401
impl<I: Interner> TypeVisitor<I> for HasTypeFlagsVisitor {
402402
type Result = ControlFlow<FoundFlags>;
403403

404-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
404+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
405405
// If we're looking for the HAS_BINDER_VARS flag, check if the
406406
// binder has vars. This won't be present in the binder's bound
407407
// value, so we need to check here too.
@@ -510,7 +510,7 @@ struct HasEscapingVarsVisitor {
510510
impl<I: Interner> TypeVisitor<I> for HasEscapingVarsVisitor {
511511
type Result = ControlFlow<FoundEscapingVars>;
512512

513-
fn visit_binder<T: TypeFoldable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
513+
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::Result {
514514
self.outer_index.shift_in(1);
515515
let result = t.super_visit_with(self);
516516
self.outer_index.shift_out(1);

src/tools/clippy/clippy_utils/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ pub fn for_each_top_level_late_bound_region<B>(
853853
ControlFlow::Continue(())
854854
}
855855
}
856-
fn visit_binder<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) -> Self::Result {
856+
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) -> Self::Result {
857857
self.index += 1;
858858
let res = t.super_visit_with(self);
859859
self.index -= 1;

0 commit comments

Comments
 (0)