Skip to content

Commit e6a81b2

Browse files
committed
switch to a multipart suggestion
1 parent 4c6792a commit e6a81b2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

clippy_lints/src/duplicate_match_guard.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use clippy_utils::diagnostics::span_lint_and_sugg;
1+
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::eq_expr_value;
33
use clippy_utils::source::snippet_with_applicability;
44
use rustc_errors::Applicability;
55
use rustc_hir::{Arm, ExprKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::declare_lint_pass;
8+
use rustc_span::Span;
89

910
declare_clippy_lint! {
1011
/// ### What it does
@@ -97,14 +98,18 @@ impl<'tcx> LateLintPass<'tcx> for DuplicateMatchGuard {
9798
//
9899
// suggest removing the `if` _and_ the curlies of the inner brace,
99100
// since the arm body already has braces
100-
span_lint_and_sugg(
101+
span_lint_and_then(
101102
cx,
102103
DUPLICATE_MATCH_GUARD,
103104
arm_body_expr.span,
104105
"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+
},
108113
);
109114
} else {
110115
// the uncommon case (rusfmt would add the braces here automatically)

0 commit comments

Comments
 (0)