From 6b0440e26d3e51aef9841ac47914b729416b25c9 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 8 Apr 2019 21:40:52 -0400 Subject: [PATCH] Cleanup argument parsing --- src/bin/miri.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 7f15d00e2c8..6e68f803f85 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -146,23 +146,22 @@ fn main() { "--" => { after_dashdash = true; } - _ => { - let split: Vec = arg.split("-Zmiri-seed=").map(|s| s.to_owned()).collect(); - if split.len() == 2 { - if seed.is_some() { - panic!("Cannot specify -Zmiri-seed multiple times!"); - } - let seed_raw = hex::decode(&split[1]).unwrap(); - if seed_raw.len() > 8 { - panic!(format!("-Zmiri-seed must be at most 8 bytes, was {}", seed_raw.len())); - } - - let mut bytes = [0; 8]; - bytes[..seed_raw.len()].copy_from_slice(&hex::decode(&split[1]).unwrap()); - seed = Some(u64::from_be_bytes(bytes)); - } else { - rustc_args.push(arg); + arg if arg.starts_with("-Zmiri-seed=") => { + if seed.is_some() { + panic!("Cannot specify -Zmiri-seed multiple times!"); } + let seed_raw = hex::decode(arg.trim_start_matches("-Zmiri-seed=")).unwrap(); + if seed_raw.len() > 8 { + panic!(format!("-Zmiri-seed must be at most 8 bytes, was {}", seed_raw.len())); + } + + let mut bytes = [0; 8]; + bytes[..seed_raw.len()].copy_from_slice(&seed_raw); + seed = Some(u64::from_be_bytes(bytes)); + + }, + _ => { + rustc_args.push(arg); } } }