Skip to content

Commit d792072

Browse files
committed
compiletest: Generic support for "no-" versions of boolean directives.
1 parent 4817259 commit d792072

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/tools/compiletest/src/header.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ impl Config {
725725
&& matches!(line.as_bytes().get(directive.len()), None | Some(&b' ') | Some(&b':'))
726726
}
727727

728+
fn parse_negative_name_directive(&self, line: &str, directive: &str) -> bool {
729+
line.starts_with("no-") && self.parse_name_directive(&line[3..], directive)
730+
}
731+
728732
pub fn parse_name_value_directive(&self, line: &str, directive: &str) -> Option<String> {
729733
let colon = directive.len();
730734
if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') {
@@ -754,8 +758,17 @@ impl Config {
754758
}
755759

756760
fn set_name_directive(&self, line: &str, directive: &str, value: &mut bool) {
757-
if !*value {
758-
*value = self.parse_name_directive(line, directive)
761+
match value {
762+
true => {
763+
if self.parse_negative_name_directive(line, directive) {
764+
*value = false;
765+
}
766+
}
767+
false => {
768+
if self.parse_name_directive(line, directive) {
769+
*value = true;
770+
}
771+
}
759772
}
760773
}
761774

0 commit comments

Comments
 (0)