Skip to content

Commit

Permalink
Split TypeVisitableExt from TypeVisitable
Browse files Browse the repository at this point in the history
  • Loading branch information
eggyal committed Feb 13, 2023
1 parent ba55a45 commit 36d09e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,6 @@ impl<'tcx> ir::TypeVisitable<'tcx> for ty::Predicate<'tcx> {
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
visitor.visit_predicate(*self)
}

#[inline]
fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool {
self.outer_exclusive_binder() > binder
}

#[inline]
fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
self.flags().intersects(flags)
}
}

impl<'tcx> TypeSuperFoldable<'tcx> for ty::Predicate<'tcx> {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ty/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sso::SsoHashSet;
use std::ops::ControlFlow;

pub trait TypeVisitable<'tcx> = ir::TypeVisitable<'tcx>;
pub trait TypeVisitable<'tcx> = ir::TypeVisitable<'tcx> + ir::TypeVisitableExt<'tcx>;
pub trait TypeSuperVisitable<'tcx> = ir::TypeSuperVisitable<'tcx>;
pub trait TypeVisitor<'tcx> = ir::TypeVisitor<'tcx>;

Expand Down Expand Up @@ -74,7 +74,9 @@ pub mod ir {
/// `V::visit_ty`). This is where control transfers from `TypeFoldable` to
/// `TypeVisitor`.
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
}

pub trait TypeVisitableExt<'tcx>: TypeVisitable<'tcx> {
/// Returns `true` if `self` has any late-bound regions that are either
/// bound by `binder` or bound by some binder outside of `binder`.
/// If `binder` is `ty::INNERMOST`, this indicates whether
Expand Down Expand Up @@ -197,6 +199,8 @@ pub mod ir {
}
}

impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitableExt<'tcx> for T {}

pub trait TypeSuperVisitable<'tcx>: TypeVisitable<'tcx> {
/// Provides a default visit for a type of interest. This should only be
/// called within `TypeVisitor` methods, when a non-custom traversal is
Expand Down

0 comments on commit 36d09e3

Please sign in to comment.