Skip to content

Commit

Permalink
Convert TypeVisitor and DefIdVisitor to use VisitorResult
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Mar 5, 2024
1 parent ae710de commit 0901b9f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/useless_asref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ fn get_enum_ty(enum_ty: Ty<'_>) -> Option<Ty<'_>> {
}

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)
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/mir/possible_borrower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b,
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(())
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ pub fn for_each_top_level_late_bound_region<B>(
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
{
Expand All @@ -926,7 +926,7 @@ pub fn for_each_top_level_late_bound_region<B>(
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;
Expand Down

0 comments on commit 0901b9f

Please sign in to comment.