@@ -10,7 +10,10 @@ use rustc_span::{source_map::Span, sym, Symbol};
1010
1111use if_chain:: if_chain;
1212
13- use crate :: utils:: { has_iter_method, is_trait_method, snippet_with_applicability, span_lint_and_then} ;
13+ use clippy_utils:: diagnostics:: span_lint_and_then;
14+ use clippy_utils:: is_trait_method;
15+ use clippy_utils:: source:: snippet_with_applicability;
16+ use clippy_utils:: ty:: has_iter_method;
1417
1518declare_clippy_lint ! {
1619 /// **What it does:** Checks for usage of `for_each` that would be more simply written as a
@@ -104,18 +107,12 @@ impl LateLintPass<'_> for NeedlessForEach {
104107 snippet_with_applicability( cx, body. value. span, ".." , & mut applicability) ,
105108 ) ;
106109
107- span_lint_and_then(
108- cx,
109- NEEDLESS_FOR_EACH ,
110- stmt. span,
111- "needless use of `for_each`" ,
112- |diag| {
113- diag. span_suggestion( stmt. span, "try" , sugg, applicability) ;
114- if let Some ( ret_suggs) = ret_suggs {
115- diag. multipart_suggestion( "try replacing `return` with `continue`" , ret_suggs, applicability) ;
116- }
110+ span_lint_and_then( cx, NEEDLESS_FOR_EACH , stmt. span, "needless use of `for_each`" , |diag| {
111+ diag. span_suggestion( stmt. span, "try" , sugg, applicability) ;
112+ if let Some ( ret_suggs) = ret_suggs {
113+ diag. multipart_suggestion( "...and replace `return` with `continue`" , ret_suggs, applicability) ;
117114 }
118- )
115+ } )
119116 }
120117 }
121118 }
0 commit comments