Skip to content

Commit f5d11d6

Browse files
committed
[semicolon_if_nothing_returned]: add an autofix
1 parent 2b03bb0 commit f5d11d6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

clippy_lints/src/semicolon_if_nothing_returned.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::rustc_lint::LintContext;
2-
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::source::snippet_with_context;
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
@@ -52,14 +52,19 @@ impl<'tcx> LateLintPass<'tcx> for SemicolonIfNothingReturned {
5252
if let ExprKind::DropTemps(..) = &expr.kind {
5353
return;
5454
}
55-
span_lint_and_sugg(
55+
span_lint_and_then(
5656
cx,
5757
SEMICOLON_IF_NOTHING_RETURNED,
5858
expr.span.source_callsite(),
5959
"consider adding a `;` to the last statement for consistent formatting",
60-
"add a `;` here",
61-
format!("{snippet};"),
62-
app,
60+
|diag| {
61+
diag.span_suggestion(
62+
expr.span,
63+
"add a `;` here",
64+
format!("{snippet};"),
65+
Applicability::MachineApplicable,
66+
);
67+
}
6368
);
6469
}
6570
}

0 commit comments

Comments
 (0)