Skip to content

Commit 856dbac

Browse files
Jakub Wieczorekgraydon
Jakub Wieczorek
authored andcommitted
Use the same logic for _ and [..tail] when checking reachability
1 parent 1968cb3 commit 856dbac

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/librustc/middle/check_alt.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ enum ctor {
173173
variant(def_id),
174174
val(const_val),
175175
range(const_val, const_val),
176-
vec(uint),
177-
vec_with_tail(uint)
176+
vec(uint)
178177
}
179178

180179
impl ctor : cmp::Eq {
@@ -189,11 +188,8 @@ impl ctor : cmp::Eq {
189188
(*cv0_self) == (*cv0_other) && (*cv1_self) == (*cv1_other)
190189
}
191190
(vec(n_self), vec(n_other)) => n_self == n_other,
192-
(vec_with_tail(n_self), vec_with_tail(n_other)) => {
193-
n_self == n_other
194-
}
195191
(single, _) | (variant(_), _) | (val(_), _) |
196-
(range(*), _) | (vec(*), _) | (vec_with_tail(*), _) => {
192+
(range(*), _) | (vec(*), _) => {
197193
false
198194
}
199195
}
@@ -328,7 +324,7 @@ fn pat_ctor_id(cx: @AltCheckCtxt, p: @pat) -> Option<ctor> {
328324
}
329325
pat_vec(elems, tail) => {
330326
match tail {
331-
Some(_) => Some(vec_with_tail(elems.len())),
327+
Some(_) => None,
332328
None => Some(vec(elems.len()))
333329
}
334330
}
@@ -465,7 +461,7 @@ fn ctor_arity(cx: @AltCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
465461
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
466462
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
467463
match ctor {
468-
vec(n) | vec_with_tail(n) => n,
464+
vec(n) => n,
469465
_ => 0u
470466
}
471467
}
@@ -614,19 +610,12 @@ fn specialize(cx: @AltCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint,
614610
}
615611
pat_vec(elems, tail) => {
616612
match ctor_id {
617-
vec_with_tail(_) => {
618-
if elems.len() >= arity {
619-
Some(vec::append(elems.slice(0, arity), vec::tail(r)))
620-
} else {
621-
None
622-
}
623-
}
624613
vec(_) => {
625614
if elems.len() < arity && tail.is_some() {
626615
Some(vec::append(
627616
vec::append(elems, vec::from_elem(
628-
arity - elems.len(), wild())
629-
),
617+
arity - elems.len(), wild()
618+
)),
630619
vec::tail(r)
631620
))
632621
} else if elems.len() == arity {

0 commit comments

Comments
 (0)