lint: port unused delimiter diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
2829f519a0
commit
fc4f8d9bc2
2 changed files with 12 additions and 5 deletions
|
@ -278,3 +278,6 @@ lint-path-statement-drop = path statement drops value
|
||||||
.suggestion = use `drop` to clarify the intent
|
.suggestion = use `drop` to clarify the intent
|
||||||
|
|
||||||
lint-path-statement-no-effect = path statement with no effect
|
lint-path-statement-no-effect = path statement with no effect
|
||||||
|
|
||||||
|
lint-unused-delim = unnecessary {$delim} around {$item}
|
||||||
|
.suggestion = remove these {$delim}
|
||||||
|
|
|
@ -544,15 +544,19 @@ trait UnusedDelimLint {
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.struct_span_lint(self.lint(), MultiSpan::from(vec![spans.0, spans.1]), |lint| {
|
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![
|
let replacement = vec![
|
||||||
(spans.0, if keep_space.0 { " ".into() } else { "".into() }),
|
(spans.0, if keep_space.0 { " ".into() } else { "".into() }),
|
||||||
(spans.1, if keep_space.1 { " ".into() } else { "".into() }),
|
(spans.1, if keep_space.1 { " ".into() } else { "".into() }),
|
||||||
];
|
];
|
||||||
let suggestion = format!("remove these {}", Self::DELIM_STR);
|
lint.build(fluent::lint::unused_delim)
|
||||||
err.multipart_suggestion(&suggestion, replacement, Applicability::MachineApplicable);
|
.set_arg("delim", Self::DELIM_STR)
|
||||||
err.emit();
|
.set_arg("item", msg)
|
||||||
|
.multipart_suggestion(
|
||||||
|
fluent::lint::suggestion,
|
||||||
|
replacement,
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue