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,35 +293,30 @@ fn build_options<O: Default>(
|
||||||
None => (option, None),
|
None => (option, None),
|
||||||
Some((k, v)) => (k.to_string(), Some(v)),
|
Some((k, v)) => (k.to_string(), Some(v)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let option_to_lookup = key.replace("-", "_");
|
let option_to_lookup = key.replace("-", "_");
|
||||||
let mut found = false;
|
match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
|
||||||
for &(candidate, setter, type_desc, _) in descrs {
|
Some((_, setter, type_desc, _)) => {
|
||||||
if option_to_lookup != candidate {
|
if !setter(&mut op, value) {
|
||||||
continue;
|
match value {
|
||||||
}
|
None => early_error(
|
||||||
if !setter(&mut op, value) {
|
error_format,
|
||||||
match value {
|
&format!(
|
||||||
None => early_error(
|
"{0} option `{1}` requires {2} ({3} {1}=<value>)",
|
||||||
error_format,
|
outputname, key, type_desc, prefix
|
||||||
&format!(
|
),
|
||||||
"{0} option `{1}` requires {2} ({3} {1}=<value>)",
|
|
||||||
outputname, key, type_desc, prefix
|
|
||||||
),
|
),
|
||||||
),
|
Some(value) => early_error(
|
||||||
Some(value) => early_error(
|
error_format,
|
||||||
error_format,
|
&format!(
|
||||||
&format!(
|
"incorrect value `{}` for {} option `{}` - {} was expected",
|
||||||
"incorrect value `{}` for {} option `{}` - {} was expected",
|
value, outputname, key, type_desc
|
||||||
value, outputname, key, type_desc
|
),
|
||||||
),
|
),
|
||||||
),
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found = true;
|
None => early_error(error_format, &format!("unknown {} option: `{}`", outputname, key)),
|
||||||
break;
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
early_error(error_format, &format!("unknown {} option: `{}`", outputname, key));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return op;
|
return op;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue