lint: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
ea5d258a75
commit
21d3bbd8b6
2 changed files with 20 additions and 26 deletions
|
@ -88,34 +88,13 @@ pub struct BuiltinEllpisisInclusiveRangePatterns {
|
|||
pub replace: String,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note(lint::requested_level)]
|
||||
pub struct RequestedLevel {
|
||||
pub level: Level,
|
||||
pub lint_name: String,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RequestedLevel {
|
||||
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
|
||||
where
|
||||
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
|
||||
{
|
||||
diag.note(fluent::lint::requested_level);
|
||||
diag.set_arg(
|
||||
"level",
|
||||
match self.level {
|
||||
Level::Allow => "-A",
|
||||
Level::Warn => "-W",
|
||||
Level::ForceWarn(_) => "--force-warn",
|
||||
Level::Deny => "-D",
|
||||
Level::Forbid => "-F",
|
||||
Level::Expect(_) => {
|
||||
unreachable!("lints with the level of `expect` should not run this code");
|
||||
}
|
||||
},
|
||||
);
|
||||
diag.set_arg("lint_name", self.lint_name);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(lint::unsupported_group, code = "E0602")]
|
||||
pub struct UnsupportedGroup {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue