refactor(toml): Inline TomlLintLevel::flag

This commit is contained in:
Ed Page 2023-11-21 19:57:48 -06:00
parent d8b9b992dd
commit a774d8b025

View file

@ -1331,7 +1331,13 @@ fn lints_to_rustflags(lints: &schema::TomlLints) -> Vec<String> {
.iter()
.flat_map(|(tool, lints)| {
lints.iter().map(move |(name, config)| {
let flag = config.level().flag();
let flag = match config.level() {
schema::TomlLintLevel::Forbid => "--forbid",
schema::TomlLintLevel::Deny => "--deny",
schema::TomlLintLevel::Warn => "--warn",
schema::TomlLintLevel::Allow => "--allow",
};
let option = if tool == "rust" {
format!("{flag}={name}")
} else {
@ -2261,17 +2267,6 @@ impl schema::InheritableLints {
}
}
impl schema::TomlLintLevel {
fn flag(&self) -> &'static str {
match self {
Self::Forbid => "--forbid",
Self::Deny => "--deny",
Self::Warn => "--warn",
Self::Allow => "--allow",
}
}
}
pub trait ResolveToPath {
fn resolve(&self, config: &Config) -> PathBuf;
}