Skip to content

Commit b6ae1fa

Browse files
Rollup merge of #78278 - lcnr:predicate-visit, r=matthewjasper
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
2 parents eaa9823 + 972d9e8 commit b6ae1fa

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

compiler/rustc_middle/src/ty/fold.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
//!
3131
//! These methods return true to indicate that the visitor has found what it is
3232
//! looking for, and does not need to visit anything else.
33-
34-
use crate::ty::structural_impls::PredicateVisitor;
3533
use crate::ty::{self, flags::FlagComputation, Binder, Ty, TyCtxt, TypeFlags};
3634
use rustc_hir as hir;
3735
use rustc_hir::def_id::DefId;
@@ -211,6 +209,10 @@ pub trait TypeVisitor<'tcx>: Sized {
211209
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
212210
c.super_visit_with(self)
213211
}
212+
213+
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> bool {
214+
p.super_visit_with(self)
215+
}
214216
}
215217

216218
///////////////////////////////////////////////////////////////////////////
@@ -868,9 +870,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
868870
_ => ct.super_visit_with(self),
869871
}
870872
}
871-
}
872873

873-
impl<'tcx> PredicateVisitor<'tcx> for HasEscapingVarsVisitor {
874874
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
875875
predicate.inner.outer_exclusive_binder > self.outer_index
876876
}
@@ -903,9 +903,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
903903
debug!("HasTypeFlagsVisitor: c={:?} c.flags={:?} self.flags={:?}", c, flags, self.flags);
904904
flags.intersects(self.flags)
905905
}
906-
}
907906

908-
impl<'tcx> PredicateVisitor<'tcx> for HasTypeFlagsVisitor {
909907
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
910908
debug!(
911909
"HasTypeFlagsVisitor: predicate={:?} predicate.flags={:?} self.flags={:?}",
@@ -914,6 +912,7 @@ impl<'tcx> PredicateVisitor<'tcx> for HasTypeFlagsVisitor {
914912
predicate.inner.flags.intersects(self.flags)
915913
}
916914
}
915+
917916
/// Collects all the late-bound regions at the innermost binding level
918917
/// into a hash set.
919918
struct LateBoundRegionsCollector {

compiler/rustc_middle/src/ty/structural_impls.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1040,16 +1040,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
10401040
}
10411041
}
10421042

1043-
pub(super) trait PredicateVisitor<'tcx>: TypeVisitor<'tcx> {
1044-
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool;
1045-
}
1046-
1047-
impl<T: TypeVisitor<'tcx>> PredicateVisitor<'tcx> for T {
1048-
default fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
1049-
predicate.super_visit_with(self)
1050-
}
1051-
}
1052-
10531043
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
10541044
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
10551045
fold_list(*self, folder, |tcx, v| tcx.intern_predicates(v))

0 commit comments

Comments
 (0)