File tree Expand file tree Collapse file tree 2 files changed +30
-32
lines changed Expand file tree Collapse file tree 2 files changed +30
-32
lines changed Original file line number Diff line number Diff line change 1
- use clippy_utils:: diagnostics:: { span_lint_and_sugg, span_lint_and_then } ;
1
+ use clippy_utils:: diagnostics:: span_lint_and_sugg;
2
2
use clippy_utils:: source:: { HasSession , snippet_with_applicability} ;
3
3
use clippy_utils:: { eq_expr_value, span_contains_comment} ;
4
4
use rustc_errors:: Applicability ;
@@ -111,25 +111,23 @@ impl<'tcx> LateLintPass<'tcx> for DuplicateMatchGuards {
111
111
return ;
112
112
}
113
113
114
- span_lint_and_then (
114
+ let sugg = snippet_with_applicability (
115
+ cx,
116
+ then. span
117
+ . with_lo ( then. span . lo ( ) + BytePos ( 1 ) )
118
+ . with_hi ( then. span . hi ( ) - BytePos ( 1 ) ) ,
119
+ ".." ,
120
+ & mut applicability,
121
+ ) ;
122
+
123
+ span_lint_and_sugg (
115
124
cx,
116
125
DUPLICATE_MATCH_GUARDS ,
117
126
arm_body_expr. span ,
118
127
"condition duplicates match guard" ,
119
- |diag| {
120
- diag. multipart_suggestion_verbose (
121
- "remove the condition" ,
122
- vec ! [
123
- // <pat> if <guard> => { if <cond> { <then_without_curlies> } }
124
- // ^^^^^^^^^^^
125
- ( arm_body_expr. span. with_hi( then. span. lo( ) + BytePos ( 1 ) ) , String :: new( ) ) ,
126
- // <pat> if <guard> => { if <cond> { <then_without_curlies> } }
127
- // ^^
128
- ( arm_body_expr. span. with_lo( then. span. hi( ) - BytePos ( 1 ) ) , String :: new( ) ) ,
129
- ] ,
130
- applicability,
131
- ) ;
132
- } ,
128
+ "remove the condition" ,
129
+ sugg. to_string ( ) ,
130
+ applicability,
133
131
) ;
134
132
} else {
135
133
// the uncommon case (rusfmt would add the braces here automatically)
Original file line number Diff line number Diff line change @@ -12,9 +12,9 @@ LL | | }
12
12
help: remove the condition
13
13
|
14
14
LL ~
15
- LL |
16
- LL | return;
17
- LL ~
15
+ LL +
16
+ LL + return;
17
+ LL +
18
18
|
19
19
20
20
error: condition duplicates match guard
@@ -29,9 +29,9 @@ LL | | }
29
29
help: remove the condition
30
30
|
31
31
LL ~
32
- LL |
33
- LL | return;
34
- LL ~
32
+ LL +
33
+ LL + return;
34
+ LL +
35
35
|
36
36
37
37
error: condition duplicates match guard
@@ -46,9 +46,9 @@ LL | | }
46
46
help: remove the condition
47
47
|
48
48
LL ~
49
- LL |
50
- LL | return;
51
- LL ~
49
+ LL +
50
+ LL + return;
51
+ LL +
52
52
|
53
53
54
54
error: condition duplicates match guard
@@ -63,9 +63,9 @@ LL | | }
63
63
help: remove the condition
64
64
|
65
65
LL ~
66
- LL |
67
- LL | return;
68
- LL ~
66
+ LL +
67
+ LL + return;
68
+ LL +
69
69
|
70
70
71
71
error: condition duplicates match guard
@@ -81,10 +81,10 @@ LL | | */}
81
81
help: remove the condition
82
82
|
83
83
LL ~
84
- LL | /*before*/
85
- LL | return;
86
- LL | /* after
87
- LL ~ */
84
+ LL + /*before*/
85
+ LL + return;
86
+ LL + /* after
87
+ LL + */
88
88
|
89
89
90
90
error: condition duplicates match guard
You can’t perform that action at this time.
0 commit comments