11use clippy_config:: msrvs:: { self , Msrv } ;
22use clippy_config:: Conf ;
33use clippy_utils:: consts:: { constant, Constant } ;
4- use clippy_utils:: diagnostics:: { multispan_sugg , span_lint_and_then} ;
4+ use clippy_utils:: diagnostics:: span_lint_and_then;
55use clippy_utils:: source:: snippet;
66use clippy_utils:: usage:: mutated_variables;
77use clippy_utils:: { eq_expr_value, higher, match_def_path, paths} ;
88use rustc_ast:: ast:: LitKind ;
9+ use rustc_errors:: Applicability ;
910use rustc_hir:: def:: Res ;
1011use rustc_hir:: intravisit:: { walk_expr, Visitor } ;
1112use rustc_hir:: { BinOpKind , BorrowKind , Expr , ExprKind } ;
@@ -14,6 +15,7 @@ use rustc_middle::ty;
1415use rustc_session:: impl_lint_pass;
1516use rustc_span:: source_map:: Spanned ;
1617use rustc_span:: Span ;
18+ use std:: iter;
1719
1820declare_clippy_lint ! {
1921 /// ### What it does
@@ -108,19 +110,19 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
108110 format ! ( "stripping a {kind_word} manually" ) ,
109111 |diag| {
110112 diag. span_note ( test_span, format ! ( "the {kind_word} was tested here" ) ) ;
111- multispan_sugg (
112- diag,
113+ diag. multipart_suggestion (
113114 format ! ( "try using the `strip_{kind_word}` method" ) ,
114- vec ! [ (
115+ iter :: once ( (
115116 test_span,
116117 format ! (
117118 "if let Some(<stripped>) = {}.strip_{kind_word}({}) " ,
118119 snippet( cx, target_arg. span, ".." ) ,
119120 snippet( cx, pattern. span, ".." )
120121 ) ,
121- ) ]
122- . into_iter ( )
123- . chain ( strippings. into_iter ( ) . map ( |span| ( span, "<stripped>" . into ( ) ) ) ) ,
122+ ) )
123+ . chain ( strippings. into_iter ( ) . map ( |span| ( span, "<stripped>" . into ( ) ) ) )
124+ . collect ( ) ,
125+ Applicability :: HasPlaceholders ,
124126 ) ;
125127 } ,
126128 ) ;
@@ -183,9 +185,9 @@ fn peel_ref<'a>(expr: &'a Expr<'_>) -> &'a Expr<'a> {
183185 }
184186}
185187
186- // Find expressions where `target` is stripped using the length of `pattern`.
187- // We'll suggest replacing these expressions with the result of the `strip_{prefix,suffix}`
188- // method.
188+ /// Find expressions where `target` is stripped using the length of `pattern`.
189+ /// We'll suggest replacing these expressions with the result of the `strip_{prefix,suffix}`
190+ /// method.
189191fn find_stripping < ' tcx > (
190192 cx : & LateContext < ' tcx > ,
191193 strip_kind : StripKind ,
0 commit comments