move visit_predicate
into TypeVisitor
This commit is contained in:
parent
a9cd294cf2
commit
972d9e886c
@ -30,8 +30,6 @@
|
||||
//!
|
||||
//! These methods return true to indicate that the visitor has found what it is
|
||||
//! looking for, and does not need to visit anything else.
|
||||
|
||||
use crate::ty::structural_impls::PredicateVisitor;
|
||||
use crate::ty::{self, flags::FlagComputation, Binder, Ty, TyCtxt, TypeFlags};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -211,6 +209,10 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
|
||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
|
||||
c.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> bool {
|
||||
p.super_visit_with(self)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -868,9 +870,7 @@ fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> bool {
|
||||
_ => ct.super_visit_with(self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
predicate.inner.outer_exclusive_binder > self.outer_index
|
||||
}
|
||||
@ -903,9 +903,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
|
||||
debug!("HasTypeFlagsVisitor: c={:?} c.flags={:?} self.flags={:?}", c, flags, self.flags);
|
||||
flags.intersects(self.flags)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PredicateVisitor<'tcx> for HasTypeFlagsVisitor {
|
||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
debug!(
|
||||
"HasTypeFlagsVisitor: predicate={:?} predicate.flags={:?} self.flags={:?}",
|
||||
@ -914,6 +912,7 @@ fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
predicate.inner.flags.intersects(self.flags)
|
||||
}
|
||||
}
|
||||
|
||||
/// Collects all the late-bound regions at the innermost binding level
|
||||
/// into a hash set.
|
||||
struct LateBoundRegionsCollector {
|
||||
|
@ -1040,16 +1040,6 @@ fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) trait PredicateVisitor<'tcx>: TypeVisitor<'tcx> {
|
||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool;
|
||||
}
|
||||
|
||||
impl<T: TypeVisitor<'tcx>> PredicateVisitor<'tcx> for T {
|
||||
default fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
predicate.super_visit_with(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
|
||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
fold_list(*self, folder, |tcx, v| tcx.intern_predicates(v))
|
||||
|
Loading…
Reference in New Issue
Block a user