From 0901b9fecf32c7dd84c83c454d30cbce11cbf2ea Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sat, 24 Feb 2024 17:22:28 -0500 Subject: [PATCH] Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult` --- clippy_lints/src/methods/useless_asref.rs | 4 ++-- clippy_utils/src/mir/possible_borrower.rs | 4 ++-- clippy_utils/src/ty.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index 514015af045..b8baad18cc8 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -22,9 +22,9 @@ struct ContainsTyVisitor { } impl<'tcx> TypeVisitor> for ContainsTyVisitor { - type BreakTy = Ty<'tcx>; + type Result = ControlFlow>; - fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { + fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result { self.level += 1; if self.level == 1 { t.super_visit_with(self) diff --git a/clippy_utils/src/mir/possible_borrower.rs b/clippy_utils/src/mir/possible_borrower.rs index f9cc5f19125..06229ac938f 100644 --- a/clippy_utils/src/mir/possible_borrower.rs +++ b/clippy_utils/src/mir/possible_borrower.rs @@ -141,9 +141,9 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca struct ContainsRegion; impl TypeVisitor> for ContainsRegion { - type BreakTy = (); + type Result = ControlFlow<()>; - fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow { + fn visit_region(&mut self, _: ty::Region<'_>) -> Self::Result { ControlFlow::Break(()) } } diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 6762c883005..6e011a28bb7 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -916,8 +916,8 @@ struct V { f: F, } impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow> TypeVisitor> for V { - type BreakTy = B; - fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow { + type Result = ControlFlow; + 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 { ControlFlow::Continue(()) } } - fn visit_binder>>(&mut self, t: &Binder<'tcx, T>) -> ControlFlow { + fn visit_binder>>(&mut self, t: &Binder<'tcx, T>) -> Self::Result { self.index += 1; let res = t.super_visit_with(self); self.index -= 1;