Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Nov 13, 2024
1 parent 3c68417 commit dad667b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
pub fn get_clippy_rules_in_order(all_args: &[String], config: &LintConfig) -> Vec<String> {
let mut result = vec![];

for (prefix, item) in
Expand All @@ -86,11 +86,11 @@ fn get_clippy_rules_in_order(all_args: &[String], config: &LintConfig) -> Vec<St
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct LintConfig {
allow: Vec<String>,
warn: Vec<String>,
deny: Vec<String>,
forbid: Vec<String>,
pub struct LintConfig {
pub allow: Vec<String>,
pub warn: Vec<String>,
pub deny: Vec<String>,
pub forbid: Vec<String>,
}

impl LintConfig {
Expand Down
12 changes: 7 additions & 5 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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"),
};
Expand All @@ -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"),
};
Expand Down

0 comments on commit dad667b

Please sign in to comment.