1
1
use clippy_config:: msrvs:: { self , Msrv } ;
2
2
use clippy_config:: Conf ;
3
3
use 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;
5
5
use clippy_utils:: source:: snippet;
6
6
use clippy_utils:: usage:: mutated_variables;
7
7
use clippy_utils:: { eq_expr_value, higher, match_def_path, paths} ;
8
8
use rustc_ast:: ast:: LitKind ;
9
+ use rustc_errors:: Applicability ;
9
10
use rustc_hir:: def:: Res ;
10
11
use rustc_hir:: intravisit:: { walk_expr, Visitor } ;
11
12
use rustc_hir:: { BinOpKind , BorrowKind , Expr , ExprKind } ;
@@ -14,6 +15,7 @@ use rustc_middle::ty;
14
15
use rustc_session:: impl_lint_pass;
15
16
use rustc_span:: source_map:: Spanned ;
16
17
use rustc_span:: Span ;
18
+ use std:: iter;
17
19
18
20
declare_clippy_lint ! {
19
21
/// ### What it does
@@ -108,19 +110,19 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
108
110
format ! ( "stripping a {kind_word} manually" ) ,
109
111
|diag| {
110
112
diag. span_note ( test_span, format ! ( "the {kind_word} was tested here" ) ) ;
111
- multispan_sugg (
112
- diag,
113
+ diag. multipart_suggestion (
113
114
format ! ( "try using the `strip_{kind_word}` method" ) ,
114
- vec ! [ (
115
+ iter :: once ( (
115
116
test_span,
116
117
format ! (
117
118
"if let Some(<stripped>) = {}.strip_{kind_word}({}) " ,
118
119
snippet( cx, target_arg. span, ".." ) ,
119
120
snippet( cx, pattern. span, ".." )
120
121
) ,
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 ,
124
126
) ;
125
127
} ,
126
128
) ;
@@ -183,9 +185,9 @@ fn peel_ref<'a>(expr: &'a Expr<'_>) -> &'a Expr<'a> {
183
185
}
184
186
}
185
187
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.
189
191
fn find_stripping < ' tcx > (
190
192
cx : & LateContext < ' tcx > ,
191
193
strip_kind : StripKind ,
0 commit comments