File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
- use clippy_utils:: diagnostics:: span_lint_and_sugg;
1
+ use clippy_utils:: diagnostics:: { span_lint_and_sugg, span_lint_and_then } ;
2
2
use clippy_utils:: eq_expr_value;
3
3
use clippy_utils:: source:: snippet_with_applicability;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: { Arm , ExprKind } ;
6
6
use rustc_lint:: { LateContext , LateLintPass } ;
7
7
use rustc_session:: declare_lint_pass;
8
+ use rustc_span:: Span ;
8
9
9
10
declare_clippy_lint ! {
10
11
/// ### What it does
@@ -97,14 +98,18 @@ impl<'tcx> LateLintPass<'tcx> for DuplicateMatchGuard {
97
98
//
98
99
// suggest removing the `if` _and_ the curlies of the inner brace,
99
100
// since the arm body already has braces
100
- span_lint_and_sugg (
101
+ span_lint_and_then (
101
102
cx,
102
103
DUPLICATE_MATCH_GUARD ,
103
104
arm_body_expr. span ,
104
105
"condition duplicates match guard" ,
105
- "remove the condition" ,
106
- sugg. to_string ( ) ,
107
- applicability,
106
+ |diag| {
107
+ diag. multipart_suggestion_verbose (
108
+ "remove the condition" ,
109
+ vec ! [ ( remove_block_curlies( arm_body_expr. span) , sugg. to_string( ) ) ] ,
110
+ applicability,
111
+ ) ;
112
+ } ,
108
113
) ;
109
114
} else {
110
115
// the uncommon case (rusfmt would add the braces here automatically)
You can’t perform that action at this time.
0 commit comments