Adjusted PR to better match project's coding style.

This commit is contained in:
Vincent Esche
2016-01-22 17:13:17 +01:00
parent 70692ce279
commit 2c7a19a10d

View File

@@ -616,7 +616,8 @@ fn missing_constructors(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
.collect(); .collect();
all_constructors(cx, left_ty, max_slice_length) all_constructors(cx, left_ty, max_slice_length)
.into_iter() .into_iter()
.filter(|c| !used_constructors.contains(c)).collect() .filter(|c| !used_constructors.contains(c))
.collect()
} }
/// This determines the set of all possible constructors of a pattern matching /// This determines the set of all possible constructors of a pattern matching
@@ -695,8 +696,8 @@ fn is_useful(cx: &MatchCheckCtxt,
let constructors = pat_constructors(cx, v[0], left_ty, max_slice_length); let constructors = pat_constructors(cx, v[0], left_ty, max_slice_length);
if constructors.is_empty() { if constructors.is_empty() {
match &missing_constructors(cx, matrix, left_ty, max_slice_length)[..] { let constructors = missing_constructors(cx, matrix, left_ty, max_slice_length);
[] => { if constructors.is_empty() {
all_constructors(cx, left_ty, max_slice_length).into_iter().map(|c| { all_constructors(cx, left_ty, max_slice_length).into_iter().map(|c| {
match is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) { match is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) {
UsefulWithWitness(pats) => UsefulWithWitness({ UsefulWithWitness(pats) => UsefulWithWitness({
@@ -714,9 +715,7 @@ fn is_useful(cx: &MatchCheckCtxt,
result => result result => result
} }
}).find(|result| result != &NotUseful).unwrap_or(NotUseful) }).find(|result| result != &NotUseful).unwrap_or(NotUseful)
}, } else {
[constructors..] => {
let matrix = rows.iter().filter_map(|r| { let matrix = rows.iter().filter_map(|r| {
if pat_is_binding_or_wild(&cx.tcx.def_map.borrow(), raw_pat(r[0])) { if pat_is_binding_or_wild(&cx.tcx.def_map.borrow(), raw_pat(r[0])) {
Some(r[1..].to_vec()) Some(r[1..].to_vec())
@@ -737,7 +736,6 @@ fn is_useful(cx: &MatchCheckCtxt,
result => result result => result
} }
} }
}
} else { } else {
constructors.into_iter().map(|c| constructors.into_iter().map(|c|
is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness)