@@ -1748,7 +1748,7 @@ fn lint_or_fun_call<'tcx>(
1748
1748
"try this" ,
1749
1749
format!(
1750
1750
"{}.unwrap_or_default()" ,
1751
- snippet_with_applicability( cx, self_expr. span, "_ " , & mut applicability)
1751
+ snippet_with_applicability( cx, self_expr. span, ".. " , & mut applicability)
1752
1752
) ,
1753
1753
applicability,
1754
1754
) ;
@@ -2155,7 +2155,7 @@ fn lint_clone_on_ref_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::
2155
2155
return ;
2156
2156
} ;
2157
2157
2158
- let snippet = snippet_with_macro_callsite ( cx, arg. span , "_ " ) ;
2158
+ let snippet = snippet_with_macro_callsite ( cx, arg. span , ".. " ) ;
2159
2159
2160
2160
span_lint_and_sugg (
2161
2161
cx,
@@ -2191,9 +2191,9 @@ fn lint_string_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::E
2191
2191
"try this" ,
2192
2192
format ! (
2193
2193
"{}.push_str({}{})" ,
2194
- snippet_with_applicability( cx, args[ 0 ] . span, "_ " , & mut applicability) ,
2194
+ snippet_with_applicability( cx, args[ 0 ] . span, ".. " , & mut applicability) ,
2195
2195
ref_str,
2196
- snippet_with_applicability( cx, target. span, "_ " , & mut applicability)
2196
+ snippet_with_applicability( cx, target. span, ".. " , & mut applicability)
2197
2197
) ,
2198
2198
applicability,
2199
2199
) ;
@@ -2460,7 +2460,7 @@ fn lint_get_unwrap<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, get_args:
2460
2460
let mut applicability = Applicability :: MachineApplicable ;
2461
2461
let expr_ty = cx. typeck_results ( ) . expr_ty ( & get_args[ 0 ] ) ;
2462
2462
let get_args_str = if get_args. len ( ) > 1 {
2463
- snippet_with_applicability ( cx, get_args[ 1 ] . span , "_ " , & mut applicability)
2463
+ snippet_with_applicability ( cx, get_args[ 1 ] . span , ".. " , & mut applicability)
2464
2464
} else {
2465
2465
return ; // not linting on a .get().unwrap() chain or variant
2466
2466
} ;
@@ -2520,7 +2520,7 @@ fn lint_get_unwrap<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, get_args:
2520
2520
format ! (
2521
2521
"{}{}[{}]" ,
2522
2522
borrow_str,
2523
- snippet_with_applicability( cx, get_args[ 0 ] . span, "_ " , & mut applicability) ,
2523
+ snippet_with_applicability( cx, get_args[ 0 ] . span, ".. " , & mut applicability) ,
2524
2524
get_args_str
2525
2525
) ,
2526
2526
applicability,
@@ -2536,7 +2536,7 @@ fn lint_iter_skip_next(cx: &LateContext<'_>, expr: &hir::Expr<'_>, skip_args: &[
2536
2536
cx,
2537
2537
ITER_SKIP_NEXT ,
2538
2538
expr. span . trim_start ( caller. span ) . unwrap ( ) ,
2539
- "called `skip(x ).next()` on an iterator" ,
2539
+ "called `skip(.. ).next()` on an iterator" ,
2540
2540
"use `nth` instead" ,
2541
2541
hint,
2542
2542
Applicability :: MachineApplicable ,
@@ -2739,11 +2739,11 @@ fn lint_map_unwrap_or_else<'tcx>(
2739
2739
2740
2740
// lint message
2741
2741
let msg = if is_option {
2742
- "called `map(f ).unwrap_or_else(g )` on an `Option` value. This can be done more directly by calling \
2743
- `map_or_else(g, f )` instead"
2742
+ "called `map(<f> ).unwrap_or_else(<g> )` on an `Option` value. This can be done more directly by calling \
2743
+ `map_or_else(<g>, <f> )` instead"
2744
2744
} else {
2745
- "called `map(f ).unwrap_or_else(g )` on a `Result` value. This can be done more directly by calling \
2746
- `.map_or_else(g, f )` instead"
2745
+ "called `map(<f> ).unwrap_or_else(<g> )` on a `Result` value. This can be done more directly by calling \
2746
+ `.map_or_else(<g>, <f> )` instead"
2747
2747
} ;
2748
2748
// get snippets for args to map() and unwrap_or_else()
2749
2749
let map_snippet = snippet ( cx, map_args[ 1 ] . span , ".." ) ;
@@ -2809,8 +2809,8 @@ fn lint_map_or_none<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
2809
2809
if is_option {
2810
2810
let self_snippet = snippet ( cx, map_or_args[ 0 ] . span , ".." ) ;
2811
2811
let func_snippet = snippet ( cx, map_or_args[ 2 ] . span , ".." ) ;
2812
- let msg = "called `map_or(None, f )` on an `Option` value. This can be done more directly by calling \
2813
- `and_then(f )` instead";
2812
+ let msg = "called `map_or(None, .. )` on an `Option` value. This can be done more directly by calling \
2813
+ `and_then(.. )` instead";
2814
2814
(
2815
2815
OPTION_MAP_OR_NONE ,
2816
2816
msg,
@@ -2848,8 +2848,8 @@ fn lint_map_or_none<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
2848
2848
fn lint_filter_next < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx hir:: Expr < ' _ > , filter_args : & ' tcx [ hir:: Expr < ' _ > ] ) {
2849
2849
// lint if caller of `.filter().next()` is an Iterator
2850
2850
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2851
- let msg = "called `filter(p ).next()` on an `Iterator`. This is more succinctly expressed by calling \
2852
- `.find(p )` instead.";
2851
+ let msg = "called `filter(.. ).next()` on an `Iterator`. This is more succinctly expressed by calling \
2852
+ `.find(.. )` instead.";
2853
2853
let filter_snippet = snippet ( cx, filter_args[ 1 ] . span , ".." ) ;
2854
2854
if filter_snippet. lines ( ) . count ( ) <= 1 {
2855
2855
// add note if not multi-line
@@ -2879,9 +2879,9 @@ fn lint_skip_while_next<'tcx>(
2879
2879
cx,
2880
2880
SKIP_WHILE_NEXT ,
2881
2881
expr. span ,
2882
- "called `skip_while(p ).next()` on an `Iterator`" ,
2882
+ "called `skip_while(<p> ).next()` on an `Iterator`" ,
2883
2883
None ,
2884
- "this is more succinctly expressed by calling `.find(!p )` instead" ,
2884
+ "this is more succinctly expressed by calling `.find(!<p> )` instead" ,
2885
2885
) ;
2886
2886
}
2887
2887
}
@@ -2895,7 +2895,7 @@ fn lint_filter_map<'tcx>(
2895
2895
) {
2896
2896
// lint if caller of `.filter().map()` is an Iterator
2897
2897
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2898
- let msg = "called `filter(p ).map(q )` on an `Iterator`" ;
2898
+ let msg = "called `filter(.. ).map(.. )` on an `Iterator`" ;
2899
2899
let hint = "this is more succinctly expressed by calling `.filter_map(..)` instead" ;
2900
2900
span_lint_and_help ( cx, FILTER_MAP , expr. span , msg, None , hint) ;
2901
2901
}
@@ -2904,8 +2904,8 @@ fn lint_filter_map<'tcx>(
2904
2904
/// lint use of `filter_map().next()` for `Iterators`
2905
2905
fn lint_filter_map_next < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx hir:: Expr < ' _ > , filter_args : & ' tcx [ hir:: Expr < ' _ > ] ) {
2906
2906
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2907
- let msg = "called `filter_map(p ).next()` on an `Iterator`. This is more succinctly expressed by calling \
2908
- `.find_map(p )` instead.";
2907
+ let msg = "called `filter_map(.. ).next()` on an `Iterator`. This is more succinctly expressed by calling \
2908
+ `.find_map(.. )` instead.";
2909
2909
let filter_snippet = snippet ( cx, filter_args[ 1 ] . span , ".." ) ;
2910
2910
if filter_snippet. lines ( ) . count ( ) <= 1 {
2911
2911
span_lint_and_note (
@@ -2931,7 +2931,7 @@ fn lint_find_map<'tcx>(
2931
2931
) {
2932
2932
// lint if caller of `.filter().map()` is an Iterator
2933
2933
if match_trait_method ( cx, & map_args[ 0 ] , & paths:: ITERATOR ) {
2934
- let msg = "called `find(p ).map(q )` on an `Iterator`" ;
2934
+ let msg = "called `find(.. ).map(.. )` on an `Iterator`" ;
2935
2935
let hint = "this is more succinctly expressed by calling `.find_map(..)` instead" ;
2936
2936
span_lint_and_help ( cx, FIND_MAP , expr. span , msg, None , hint) ;
2937
2937
}
@@ -2946,7 +2946,7 @@ fn lint_filter_map_map<'tcx>(
2946
2946
) {
2947
2947
// lint if caller of `.filter().map()` is an Iterator
2948
2948
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2949
- let msg = "called `filter_map(p ).map(q )` on an `Iterator`" ;
2949
+ let msg = "called `filter_map(.. ).map(.. )` on an `Iterator`" ;
2950
2950
let hint = "this is more succinctly expressed by only calling `.filter_map(..)` instead" ;
2951
2951
span_lint_and_help ( cx, FILTER_MAP , expr. span , msg, None , hint) ;
2952
2952
}
@@ -2961,7 +2961,7 @@ fn lint_filter_flat_map<'tcx>(
2961
2961
) {
2962
2962
// lint if caller of `.filter().flat_map()` is an Iterator
2963
2963
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2964
- let msg = "called `filter(p ).flat_map(q )` on an `Iterator`" ;
2964
+ let msg = "called `filter(.. ).flat_map(.. )` on an `Iterator`" ;
2965
2965
let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
2966
2966
and filtering by returning `iter::empty()`";
2967
2967
span_lint_and_help ( cx, FILTER_MAP , expr. span , msg, None , hint) ;
@@ -2977,7 +2977,7 @@ fn lint_filter_map_flat_map<'tcx>(
2977
2977
) {
2978
2978
// lint if caller of `.filter_map().flat_map()` is an Iterator
2979
2979
if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2980
- let msg = "called `filter_map(p ).flat_map(q )` on an `Iterator`" ;
2980
+ let msg = "called `filter_map(.. ).flat_map(.. )` on an `Iterator`" ;
2981
2981
let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
2982
2982
and filtering by returning `iter::empty()`";
2983
2983
span_lint_and_help ( cx, FILTER_MAP , expr. span , msg, None , hint) ;
@@ -3148,9 +3148,9 @@ fn lint_chars_cmp(
3148
3148
"like this" ,
3149
3149
format!( "{}{}.{}({})" ,
3150
3150
if info. eq { "" } else { "!" } ,
3151
- snippet_with_applicability( cx, args[ 0 ] [ 0 ] . span, "_ " , & mut applicability) ,
3151
+ snippet_with_applicability( cx, args[ 0 ] [ 0 ] . span, ".. " , & mut applicability) ,
3152
3152
suggest,
3153
- snippet_with_applicability( cx, arg_char[ 0 ] . span, "_ " , & mut applicability) ) ,
3153
+ snippet_with_applicability( cx, arg_char[ 0 ] . span, ".. " , & mut applicability) ) ,
3154
3154
applicability,
3155
3155
) ;
3156
3156
@@ -3197,7 +3197,7 @@ fn lint_chars_cmp_with_unwrap<'tcx>(
3197
3197
"like this" ,
3198
3198
format!( "{}{}.{}('{}')" ,
3199
3199
if info. eq { "" } else { "!" } ,
3200
- snippet_with_applicability( cx, args[ 0 ] [ 0 ] . span, "_ " , & mut applicability) ,
3200
+ snippet_with_applicability( cx, args[ 0 ] [ 0 ] . span, ".. " , & mut applicability) ,
3201
3201
suggest,
3202
3202
c) ,
3203
3203
applicability,
@@ -3272,7 +3272,7 @@ fn lint_single_char_pattern(cx: &LateContext<'_>, _expr: &hir::Expr<'_>, arg: &h
3272
3272
fn lint_single_char_push_string ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) {
3273
3273
let mut applicability = Applicability :: MachineApplicable ;
3274
3274
if let Some ( extension_string) = get_hint_if_single_char_arg ( cx, & args[ 1 ] , & mut applicability) {
3275
- let base_string_snippet = snippet_with_applicability ( cx, args[ 0 ] . span , "_ " , & mut applicability) ;
3275
+ let base_string_snippet = snippet_with_applicability ( cx, args[ 0 ] . span , ".. " , & mut applicability) ;
3276
3276
let sugg = format ! ( "{}.push({})" , base_string_snippet, extension_string) ;
3277
3277
span_lint_and_sugg (
3278
3278
cx,
@@ -3315,7 +3315,7 @@ fn lint_asref(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, as_re
3315
3315
expr. span ,
3316
3316
& format ! ( "this call to `{}` does nothing" , call_name) ,
3317
3317
"try this" ,
3318
- snippet_with_applicability ( cx, recvr. span , "_ " , & mut applicability) . to_string ( ) ,
3318
+ snippet_with_applicability ( cx, recvr. span , ".. " , & mut applicability) . to_string ( ) ,
3319
3319
applicability,
3320
3320
) ;
3321
3321
}
0 commit comments