Skip to content

Commit 07d56cb

Browse files
committed
Fix panic as passing wrong format to extract_gdb_version
1 parent d778f32 commit 07d56cb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,32 +132,29 @@ impl EarlyProps {
132132

133133
fn ignore_gdb(config: &Config, line: &str) -> bool {
134134
if let Some(actual_version) = config.gdb_version {
135-
if line.starts_with("min-gdb-version") {
136-
let (start_ver, end_ver) = extract_gdb_version_range(line);
135+
if let Some(rest) = line.strip_prefix("min-gdb-version:").map(str::trim) {
136+
let (start_ver, end_ver) = extract_gdb_version_range(rest);
137137

138138
if start_ver != end_ver {
139139
panic!("Expected single GDB version")
140140
}
141141
// Ignore if actual version is smaller the minimum required
142142
// version
143-
actual_version < start_ver
144-
} else if line.starts_with("ignore-gdb-version") {
145-
let (min_version, max_version) = extract_gdb_version_range(line);
143+
return actual_version < start_ver;
144+
} else if let Some(rest) = line.strip_prefix("ignore-gdb-version:").map(str::trim) {
145+
let (min_version, max_version) = extract_gdb_version_range(rest);
146146

147147
if max_version < min_version {
148148
panic!("Malformed GDB version range: max < min")
149149
}
150150

151-
actual_version >= min_version && actual_version <= max_version
152-
} else {
153-
false
151+
return actual_version >= min_version && actual_version <= max_version;
154152
}
155-
} else {
156-
false
157153
}
154+
false
158155
}
159156

160-
// Takes a directive of the form "ignore-gdb-version <version1> [- <version2>]",
157+
// Takes a directive of the form "<version1> [- <version2>]",
161158
// returns the numeric representation of <version1> and <version2> as
162159
// tuple: (<version1> as u32, <version2> as u32)
163160
// If the <version2> part is omitted, the second component of the tuple

0 commit comments

Comments
 (0)