From 4d3361658b2487154d8140b06b140e72c0227441 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sun, 16 Apr 2023 11:51:28 +0200 Subject: [PATCH] Unconditionally deny warnings for clippy --- xtask/src/cargo_command.rs | 21 +++++++++++++++++++-- xtask/src/run/mod.rs | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/xtask/src/cargo_command.rs b/xtask/src/cargo_command.rs index f399b8702d..9cf4f6505b 100644 --- a/xtask/src/cargo_command.rs +++ b/xtask/src/cargo_command.rs @@ -65,6 +65,7 @@ pub enum CargoCommand<'a> { package: Option, target: Option>, features: Option, + deny_warnings: bool, }, Format { cargoarg: &'a Option<&'a str>, @@ -244,10 +245,16 @@ impl core::fmt::Display for CargoCommand<'_> { package, target, features, + deny_warnings, } => { let details = details(target, None, features, cargoarg, None); let package = p(package); - write!(f, "Clippy {package} {details}") + let deny_warns = if *deny_warnings { + format!(" (deny warnings)") + } else { + format!("") + }; + write!(f, "Clippy{deny_warns} {package} {details}") } CargoCommand::Format { cargoarg, @@ -483,9 +490,19 @@ impl<'a> CargoCommand<'a> { cargoarg, package, features, + deny_warnings, // Target is added by build_args target: _, - } => self.build_args(true, cargoarg, features, None, p(package)), + } => { + let package = p(package); + let extra = if *deny_warnings { + vec!["--", "-D", "warnings"].into_iter() + } else { + vec![].into_iter() + }; + + self.build_args(true, cargoarg, features, None, package.chain(extra)) + } CargoCommand::Doc { cargoarg, features, diff --git a/xtask/src/run/mod.rs b/xtask/src/run/mod.rs index 035dc7a7dc..ac35f5ce81 100644 --- a/xtask/src/run/mod.rs +++ b/xtask/src/run/mod.rs @@ -279,6 +279,7 @@ pub fn cargo_clippy<'c>( package: Some(package.name()), target: target.into(), features, + deny_warnings: true, }; (globals, command, false)