Skip to content

Commit 8e83656

Browse files
committed
lint: port redundant semicolons diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent 37588d6 commit 8e83656

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

compiler/rustc_error_messages/locales/en-US/lint.ftl

+10
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,13 @@ lint-noop-method-call = call to `.{$method}()` on a reference in this situation
131131
132132
lint-pass-by-value = passing `{$ty}` by reference
133133
.suggestion = try passing by value
134+
135+
lint-redundant-semicolons =
136+
unnecessary trailing {$multiple ->
137+
[true] semicolons
138+
*[false] semicolon
139+
}
140+
.suggestion = remove {$multiple ->
141+
[true] these semicolons
142+
*[false] this semicolon
143+
}

compiler/rustc_lint/src/redundant_semicolon.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{EarlyContext, EarlyLintPass, LintContext};
22
use rustc_ast::{Block, StmtKind};
3-
use rustc_errors::Applicability;
3+
use rustc_errors::{fluent, Applicability};
44
use rustc_span::Span;
55

66
declare_lint! {
@@ -49,12 +49,10 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
4949
}
5050

5151
cx.struct_span_lint(REDUNDANT_SEMICOLONS, span, |lint| {
52-
let (msg, rem) = if multiple {
53-
("unnecessary trailing semicolons", "remove these semicolons")
54-
} else {
55-
("unnecessary trailing semicolon", "remove this semicolon")
56-
};
57-
lint.build(msg).span_suggestion(span, rem, "", Applicability::MaybeIncorrect).emit();
52+
lint.build(fluent::lint::redundant_semicolons)
53+
.set_arg("multiple", multiple)
54+
.span_suggestion(span, fluent::lint::suggestion, "", Applicability::MaybeIncorrect)
55+
.emit();
5856
});
5957
}
6058
}

0 commit comments

Comments
 (0)