Skip to content

Commit

Permalink
Rollup merge of rust-lang#132873 - onur-ozkan:132867, r=jieyouxu
Browse files Browse the repository at this point in the history
handle separate prefixes in clippy rules

Fixes rust-lang#132867
  • Loading branch information
matthiaskrgr authored and mati865 committed Nov 12, 2024
2 parents 46094d7 + 58f5b79 commit c365903
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub(crate) fn get_clippy_rules_in_order(
{
item.iter().for_each(|v| {
let rule = format!("{prefix}{v}");
let position = all_args.iter().position(|t| t == &rule).unwrap();
let position = all_args.iter().position(|t| t == &rule || t == v).unwrap();
result.push((position, rule));
});
}
Expand Down
17 changes: 17 additions & 0 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,23 @@ fn order_of_clippy_rules() {
assert_eq!(expected, actual);
}

#[test]
fn clippy_rule_separate_prefix() {
let args =
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 {
crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
get_clippy_rules_in_order(&args, &allow, &deny, &warn, &forbid)
}
_ => panic!("invalid subcommand"),
};

let expected = vec!["-A clippy:all".to_string(), "-W clippy::style".to_string()];
assert_eq!(expected, actual);
}

#[test]
fn verbose_tests_default_value() {
let config = Config::parse(Flags::parse(&["build".into(), "compiler".into()]));
Expand Down

0 comments on commit c365903

Please sign in to comment.