Convert TypeVisitor and DefIdVisitor to use VisitorResult

This commit is contained in:
Jason Newcomb 2024-02-24 17:22:28 -05:00
parent ae710de635
commit 0901b9fecf
3 changed files with 7 additions and 7 deletions

View File

@ -22,9 +22,9 @@ struct ContainsTyVisitor {
}
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTyVisitor {
type BreakTy = Ty<'tcx>;
type Result = ControlFlow<Ty<'tcx>>;
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
self.level += 1;
if self.level == 1 {
t.super_visit_with(self)

View File

@ -141,9 +141,9 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
struct ContainsRegion;
impl TypeVisitor<TyCtxt<'_>> for ContainsRegion {
type BreakTy = ();
type Result = ControlFlow<()>;
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
fn visit_region(&mut self, _: ty::Region<'_>) -> Self::Result {
ControlFlow::Break(())
}
}

View File

@ -916,8 +916,8 @@ struct V<F> {
f: F,
}
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> {
type BreakTy = B;
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
type Result = ControlFlow<B>;
fn visit_region(&mut self, r: Region<'tcx>) -> Self::Result {
if let RegionKind::ReBound(idx, bound) = r.kind()
&& idx.as_u32() == self.index
{
@ -926,7 +926,7 @@ fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::Continue(())
}
}
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) -> ControlFlow<Self::BreakTy> {
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &Binder<'tcx, T>) -> Self::Result {
self.index += 1;
let res = t.super_visit_with(self);
self.index -= 1;