From a774d8b025d17a82fe76ff7588e9cbce50817965 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 21 Nov 2023 19:57:48 -0600 Subject: [PATCH] refactor(toml): Inline TomlLintLevel::flag --- src/cargo/util/toml/mod.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index b991d472b..2a5b29b8b 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1331,7 +1331,13 @@ fn lints_to_rustflags(lints: &schema::TomlLints) -> Vec { .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; }