diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-07-11 13:48:21 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-07-19 09:29:11 +0000 |
| commit | 07d56cba8ffd854f1c8b91bb1372130e5abe6169 (patch) | |
| tree | 97ca97dce874a1e1337e3b5f1af1120699074cd9 | |
| parent | d778f326c385b2df7053b84fb5e3f89361b5fc3a (diff) | |
| download | rust-07d56cba8ffd854f1c8b91bb1372130e5abe6169.tar.gz rust-07d56cba8ffd854f1c8b91bb1372130e5abe6169.zip | |
Fix panic as passing wrong format to `extract_gdb_version`
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 0ee11608dc5..dc561352642 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -132,32 +132,29 @@ impl EarlyProps { fn ignore_gdb(config: &Config, line: &str) -> bool { if let Some(actual_version) = config.gdb_version { - if line.starts_with("min-gdb-version") { - let (start_ver, end_ver) = extract_gdb_version_range(line); + if let Some(rest) = line.strip_prefix("min-gdb-version:").map(str::trim) { + let (start_ver, end_ver) = extract_gdb_version_range(rest); if start_ver != end_ver { panic!("Expected single GDB version") } // Ignore if actual version is smaller the minimum required // version - actual_version < start_ver - } else if line.starts_with("ignore-gdb-version") { - let (min_version, max_version) = extract_gdb_version_range(line); + return actual_version < start_ver; + } else if let Some(rest) = line.strip_prefix("ignore-gdb-version:").map(str::trim) { + let (min_version, max_version) = extract_gdb_version_range(rest); if max_version < min_version { panic!("Malformed GDB version range: max < min") } - actual_version >= min_version && actual_version <= max_version - } else { - false + return actual_version >= min_version && actual_version <= max_version; } - } else { - false } + false } - // Takes a directive of the form "ignore-gdb-version <version1> [- <version2>]", + // Takes a directive of the form "<version1> [- <version2>]", // returns the numeric representation of <version1> and <version2> as // tuple: (<version1> as u32, <version2> as u32) // If the <version2> part is omitted, the second component of the tuple |
