Skip to content

Commit

Permalink
Rollup merge of #78278 - lcnr:predicate-visit, r=matthewjasper
Browse files Browse the repository at this point in the history
move `visit_predicate` into `TypeVisitor`

Seems easier than dealing with `PredicateVisitor` for me which I needed for object safety checks for `PredicateAtom::ConstEvaluatable`. Is there a reason I am missing for this split?

r? @matthewjasper
  • Loading branch information
jonas-schievink authored Oct 24, 2020
2 parents eaa9823 + 972d9e8 commit b6ae1fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -211,6 +209,10 @@ pub trait TypeVisitor<'tcx>: Sized {
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)
}
}

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -868,9 +870,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
_ => 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
}
Expand Down Expand Up @@ -903,9 +903,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
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={:?}",
Expand All @@ -914,6 +912,7 @@ impl<'tcx> PredicateVisitor<'tcx> for HasTypeFlagsVisitor {
predicate.inner.flags.intersects(self.flags)
}
}

/// Collects all the late-bound regions at the innermost binding level
/// into a hash set.
struct LateBoundRegionsCollector {
Expand Down
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 @@ -1040,16 +1040,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
}
}

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))
Expand Down

0 comments on commit b6ae1fa

Please sign in to comment.