From dad667b6ac5a4d0ed806d53932f5491df418bfaa Mon Sep 17 00:00:00 2001 From: klensy Date: Tue, 5 Nov 2024 21:19:28 +0300 Subject: [PATCH] fix tests --- src/bootstrap/src/core/build_steps/clippy.rs | 12 ++++++------ src/bootstrap/src/core/config/tests.rs | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index ad2b349bab670..0884d86cc6d5f 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -66,7 +66,7 @@ fn lint_args(builder: &Builder<'_>, config: &LintConfig, ignored_rules: &[&str]) /// We need to keep the order of the given clippy lint rules before passing them. /// Since clap doesn't offer any useful interface for this purpose out of the box, /// we have to handle it manually. -fn get_clippy_rules_in_order(all_args: &[String], config: &LintConfig) -> Vec { +pub fn get_clippy_rules_in_order(all_args: &[String], config: &LintConfig) -> Vec { let mut result = vec![]; for (prefix, item) in @@ -86,11 +86,11 @@ fn get_clippy_rules_in_order(all_args: &[String], config: &LintConfig) -> Vec, - warn: Vec, - deny: Vec, - forbid: Vec, +pub struct LintConfig { + pub allow: Vec, + pub warn: Vec, + pub deny: Vec, + pub forbid: Vec, } impl LintConfig { diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index f911581b7eece..24f932a172432 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -9,7 +9,7 @@ use serde::Deserialize; use super::flags::Flags; use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS}; -use crate::core::build_steps::clippy::get_clippy_rules_in_order; +use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order}; use crate::core::build_steps::llvm; use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig}; @@ -309,9 +309,10 @@ fn order_of_clippy_rules() { ]; let config = Config::parse(Flags::parse(&args)); - let actual = match &config.cmd { + let actual = match config.cmd.clone() { crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => { - get_clippy_rules_in_order(&args, &allow, &deny, &warn, &forbid) + let cfg = LintConfig { allow, deny, warn, forbid }; + get_clippy_rules_in_order(&args, &cfg) } _ => panic!("invalid subcommand"), }; @@ -332,9 +333,10 @@ fn clippy_rule_separate_prefix() { vec!["clippy".to_string(), "-A clippy:all".to_string(), "-W clippy::style".to_string()]; let config = Config::parse(Flags::parse(&args)); - let actual = match &config.cmd { + let actual = match config.cmd.clone() { crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => { - get_clippy_rules_in_order(&args, &allow, &deny, &warn, &forbid) + let cfg = LintConfig { allow, deny, warn, forbid }; + get_clippy_rules_in_order(&args, &cfg) } _ => panic!("invalid subcommand"), };