Skip to content

Commit 4713614

Browse files
Lambdariszhuyunxing
authored andcommitted
coverage. Allow multi options passed to coverage-options
1 parent eaa4f73 commit 4713614

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -943,32 +943,21 @@ mod parse {
943943
pub(crate) fn parse_coverage_options(slot: &mut CoverageOptions, v: Option<&str>) -> bool {
944944
let Some(v) = v else { return true };
945945

946-
let set_branch_option = |slot: &mut CoverageOptions, option: &str| {
946+
for option in v.split(',') {
947947
match option {
948-
"no-branch" => slot.branch = false,
949-
"branch" => slot.branch = true,
948+
"no-branch" => {
949+
slot.branch = false;
950+
}
951+
"branch" => {
952+
slot.branch = true;
953+
}
950954
"mcdc" => {
951-
slot.mcdc = true;
952-
slot.branch = true
955+
slot.branch = true;
956+
slot.mcdc = true
953957
}
954958
_ => return false,
955959
}
956-
true
957-
};
958-
959-
// Once an option is parsed we removed it from the array so that conflicting options such as "branch,no-branch" could be detected.
960-
let mut parsers_set: [Option<&dyn Fn(&mut CoverageOptions, &str) -> bool>; 1] =
961-
[Some(&set_branch_option)];
962-
963-
for option in v.split(',') {
964-
if !parsers_set
965-
.iter_mut()
966-
.any(|p| p.is_some_and(|parser| parser(slot, option)).then(|| p.take()).is_some())
967-
{
968-
return false;
969-
}
970960
}
971-
972961
true
973962
}
974963

0 commit comments

Comments
 (0)