Skip to content

Commit 7319666

Browse files
authored
Rollup merge of #132873 - onur-ozkan:132867, r=jieyouxu
handle separate prefixes in clippy rules Fixes #132867
2 parents 95175f8 + 469c8ba commit 7319666

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/bootstrap/src/core/build_steps/clippy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub(crate) fn get_clippy_rules_in_order(
8282
{
8383
item.iter().for_each(|v| {
8484
let rule = format!("{prefix}{v}");
85-
let position = all_args.iter().position(|t| t == &rule).unwrap();
85+
let position = all_args.iter().position(|t| t == &rule || t == v).unwrap();
8686
result.push((position, rule));
8787
});
8888
}

src/bootstrap/src/core/config/tests.rs

+17
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,23 @@ fn order_of_clippy_rules() {
323323
assert_eq!(expected, actual);
324324
}
325325

326+
#[test]
327+
fn clippy_rule_separate_prefix() {
328+
let args =
329+
vec!["clippy".to_string(), "-A clippy:all".to_string(), "-W clippy::style".to_string()];
330+
let config = Config::parse(Flags::parse(&args));
331+
332+
let actual = match &config.cmd {
333+
crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
334+
get_clippy_rules_in_order(&args, &allow, &deny, &warn, &forbid)
335+
}
336+
_ => panic!("invalid subcommand"),
337+
};
338+
339+
let expected = vec!["-A clippy:all".to_string(), "-W clippy::style".to_string()];
340+
assert_eq!(expected, actual);
341+
}
342+
326343
#[test]
327344
fn verbose_tests_default_value() {
328345
let config = Config::parse(Flags::parse(&["build".into(), "compiler".into()]));

0 commit comments

Comments
 (0)