Skip to content

Commit fc4f8d9

Browse files
committed
lint: port unused delimiter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent 2829f51 commit fc4f8d9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,6 @@ lint-path-statement-drop = path statement drops value
278278
.suggestion = use `drop` to clarify the intent
279279
280280
lint-path-statement-no-effect = path statement with no effect
281+
282+
lint-unused-delim = unnecessary {$delim} around {$item}
283+
.suggestion = remove these {$delim}

compiler/rustc_lint/src/unused.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,19 @@ trait UnusedDelimLint {
544544
}
545545

546546
cx.struct_span_lint(self.lint(), MultiSpan::from(vec![spans.0, spans.1]), |lint| {
547-
let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg);
548-
let mut err = lint.build(&span_msg);
549547
let replacement = vec![
550548
(spans.0, if keep_space.0 { " ".into() } else { "".into() }),
551549
(spans.1, if keep_space.1 { " ".into() } else { "".into() }),
552550
];
553-
let suggestion = format!("remove these {}", Self::DELIM_STR);
554-
err.multipart_suggestion(&suggestion, replacement, Applicability::MachineApplicable);
555-
err.emit();
551+
lint.build(fluent::lint::unused_delim)
552+
.set_arg("delim", Self::DELIM_STR)
553+
.set_arg("item", msg)
554+
.multipart_suggestion(
555+
fluent::lint::suggestion,
556+
replacement,
557+
Applicability::MachineApplicable,
558+
)
559+
.emit();
556560
});
557561
}
558562

0 commit comments

Comments
 (0)