1
Fork 0

create helper function for rustc_lint_defs::Level and remove it's duplicated code r=ozkanonur

Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
ozkanonur 2023-01-10 10:56:17 +03:00
parent 89e0576bd3
commit 5fb9ca3c5e
3 changed files with 15 additions and 20 deletions

View file

@ -253,6 +253,19 @@ impl Level {
}
}
pub fn to_cmd_flag(self) -> &'static str {
match self {
Level::Warn => "-W",
Level::Deny => "-D",
Level::Forbid => "-F",
Level::Allow => "-A",
Level::ForceWarn(_) => "--force-warn",
Level::Expect(_) => {
unreachable!("the expect level does not have a commandline flag")
}
}
}
pub fn is_error(self) -> bool {
match self {
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn(_) => false,