rustc_session: Use Iterator::find
instead of manual search
This commit is contained in:
parent
9d18d4df0e
commit
273e0a2a05
1 changed files with 19 additions and 24 deletions
|
@ -293,12 +293,10 @@ fn build_options<O: Default>(
|
|||
None => (option, None),
|
||||
Some((k, v)) => (k.to_string(), Some(v)),
|
||||
};
|
||||
|
||||
let option_to_lookup = key.replace("-", "_");
|
||||
let mut found = false;
|
||||
for &(candidate, setter, type_desc, _) in descrs {
|
||||
if option_to_lookup != candidate {
|
||||
continue;
|
||||
}
|
||||
match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
|
||||
Some((_, setter, type_desc, _)) => {
|
||||
if !setter(&mut op, value) {
|
||||
match value {
|
||||
None => early_error(
|
||||
|
@ -317,11 +315,8 @@ fn build_options<O: Default>(
|
|||
),
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if !found {
|
||||
early_error(error_format, &format!("unknown {} option: `{}`", outputname, key));
|
||||
None => early_error(error_format, &format!("unknown {} option: `{}`", outputname, key)),
|
||||
}
|
||||
}
|
||||
return op;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue