Skip to content

Commit 6b0440e

Browse files
committed
Cleanup argument parsing
1 parent 5530d29 commit 6b0440e

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/bin/miri.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,22 @@ fn main() {
146146
"--" => {
147147
after_dashdash = true;
148148
}
149-
_ => {
150-
let split: Vec<String> = arg.split("-Zmiri-seed=").map(|s| s.to_owned()).collect();
151-
if split.len() == 2 {
152-
if seed.is_some() {
153-
panic!("Cannot specify -Zmiri-seed multiple times!");
154-
}
155-
let seed_raw = hex::decode(&split[1]).unwrap();
156-
if seed_raw.len() > 8 {
157-
panic!(format!("-Zmiri-seed must be at most 8 bytes, was {}", seed_raw.len()));
158-
}
159-
160-
let mut bytes = [0; 8];
161-
bytes[..seed_raw.len()].copy_from_slice(&hex::decode(&split[1]).unwrap());
162-
seed = Some(u64::from_be_bytes(bytes));
163-
} else {
164-
rustc_args.push(arg);
149+
arg if arg.starts_with("-Zmiri-seed=") => {
150+
if seed.is_some() {
151+
panic!("Cannot specify -Zmiri-seed multiple times!");
152+
}
153+
let seed_raw = hex::decode(arg.trim_start_matches("-Zmiri-seed=")).unwrap();
154+
if seed_raw.len() > 8 {
155+
panic!(format!("-Zmiri-seed must be at most 8 bytes, was {}", seed_raw.len()));
165156
}
157+
158+
let mut bytes = [0; 8];
159+
bytes[..seed_raw.len()].copy_from_slice(&seed_raw);
160+
seed = Some(u64::from_be_bytes(bytes));
161+
162+
},
163+
_ => {
164+
rustc_args.push(arg);
166165
}
167166
}
168167
}

0 commit comments

Comments
 (0)