From ce56cf71d956ea78c319ff510651473ca8dce47c Mon Sep 17 00:00:00 2001 From: Raiki Tamura Date: Sat, 7 Jan 2023 20:44:02 +0900 Subject: chore --- clippy_utils/src/visitors.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clippy_utils') diff --git a/clippy_utils/src/visitors.rs b/clippy_utils/src/visitors.rs index 863fb60fcfc..14c01a60b4c 100644 --- a/clippy_utils/src/visitors.rs +++ b/clippy_utils/src/visitors.rs @@ -724,3 +724,14 @@ pub fn for_each_local_assignment<'tcx, B>( ControlFlow::Continue(()) } } + +pub fn contains_break_or_continue(expr: &Expr<'_>) -> bool { + for_each_expr(expr, |e| { + if matches!(e.kind, ExprKind::Break(..) | ExprKind::Continue(..)) { + ControlFlow::Break(()) + } else { + ControlFlow::Continue(()) + } + }) + .is_some() +} -- cgit 1.4.1-3-g733a5