diff options
| author | David Wood <david.wood@huawei.com> | 2022-06-28 10:28:57 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-06-30 08:59:22 +0100 |
| commit | fc4f8d9bc24ef3e3e3be6c22cbcab85adf21cf2d (patch) | |
| tree | bb3974c6a713fe5be6c647170d2e6591592e7edc /compiler | |
| parent | 2829f519a068addbbac9627a3d62951614677766 (diff) | |
| download | rust-fc4f8d9bc24ef3e3e3be6c22cbcab85adf21cf2d.tar.gz rust-fc4f8d9bc24ef3e3e3be6c22cbcab85adf21cf2d.zip | |
lint: port unused delimiter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/lint.ftl | 3 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/lint.ftl b/compiler/rustc_error_messages/locales/en-US/lint.ftl index e14912630dd..00ac64031ca 100644 --- a/compiler/rustc_error_messages/locales/en-US/lint.ftl +++ b/compiler/rustc_error_messages/locales/en-US/lint.ftl @@ -278,3 +278,6 @@ lint-path-statement-drop = path statement drops value .suggestion = use `drop` to clarify the intent lint-path-statement-no-effect = path statement with no effect + +lint-unused-delim = unnecessary {$delim} around {$item} + .suggestion = remove these {$delim} diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index a3a879b333b..e163c9add31 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -544,15 +544,19 @@ trait UnusedDelimLint { } cx.struct_span_lint(self.lint(), MultiSpan::from(vec![spans.0, spans.1]), |lint| { - let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg); - let mut err = lint.build(&span_msg); let replacement = vec![ (spans.0, if keep_space.0 { " ".into() } else { "".into() }), (spans.1, if keep_space.1 { " ".into() } else { "".into() }), ]; - let suggestion = format!("remove these {}", Self::DELIM_STR); - err.multipart_suggestion(&suggestion, replacement, Applicability::MachineApplicable); - err.emit(); + lint.build(fluent::lint::unused_delim) + .set_arg("delim", Self::DELIM_STR) + .set_arg("item", msg) + .multipart_suggestion( + fluent::lint::suggestion, + replacement, + Applicability::MachineApplicable, + ) + .emit(); }); } |
