@@ -265,7 +265,7 @@ pub fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: &[@pat]) -> useful {
265265 Some(ref ctor) => {
266266 match is_useful(cx,
267267 vec::filter_map(m, |r| default(cx, r)),
268- vec:: tail(v )) {
268+ v. tail()) {
269269 useful_ => useful(left_ty, (/*bad*/copy *ctor)),
270270 ref u => (/*bad*/copy *u)
271271 }
@@ -281,7 +281,7 @@ pub fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: &[@pat]) -> useful {
281281
282282pub fn is_useful_specialized(cx: @MatchCheckCtxt,
283283 m: matrix,
284- + v: &[@pat],
284+ v: &[@pat],
285285 +ctor: ctor,
286286 arity: uint,
287287 lty: ty::t)
@@ -475,7 +475,7 @@ pub fn wild() -> @pat {
475475}
476476
477477pub fn specialize(cx: @MatchCheckCtxt,
478- + r: &[@pat],
478+ r: &[@pat],
479479 ctor_id: ctor,
480480 arity: uint,
481481 left_ty: ty::t)
@@ -485,13 +485,17 @@ pub fn specialize(cx: @MatchCheckCtxt,
485485 match r0 {
486486 pat{id: pat_id, node: n, span: pat_span} =>
487487 match n {
488- pat_wild => Some(vec::append(vec::from_elem(arity, wild()),
489- vec::tail(r))),
488+ pat_wild => {
489+ Some(vec::append(vec::from_elem(arity, wild()), r.tail()))
490+ }
490491 pat_ident(_, _, _) => {
491492 match cx.tcx.def_map.find(&pat_id) {
492493 Some(def_variant(_, id)) => {
493- if variant(id) == ctor_id { Some(vec::tail(r)) }
494- else { None }
494+ if variant(id) == ctor_id {
495+ Some(vec::from_slice(r.tail()))
496+ } else {
497+ None
498+ }
495499 }
496500 Some(def_const(did)) => {
497501 let const_expr =
@@ -506,10 +510,20 @@ pub fn specialize(cx: @MatchCheckCtxt,
506510 single => true,
507511 _ => fail!(~" type error")
508512 };
509- if match_ { Some(vec::tail(r)) } else { None }
513+ if match_ {
514+ Some(vec::from_slice(r.tail()))
515+ } else {
516+ None
517+ }
518+ }
519+ _ => {
520+ Some(
521+ vec::append(
522+ vec::from_elem(arity, wild()),
523+ r.tail()
524+ )
525+ )
510526 }
511- _ => Some(vec::append(vec::from_elem(arity, wild()),
512- vec::tail(r)))
513527 }
514528 }
515529 pat_enum(_, args) => {
@@ -519,7 +533,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
519533 Some(args) => args,
520534 None => vec::from_elem(arity, wild())
521535 };
522- Some(vec::append(args, vec::tail(r )))
536+ Some(vec::append(args, vec::from_slice(r.tail() )))
523537 }
524538 def_variant(_, _) => None,
525539 def_struct(*) => {
@@ -529,7 +543,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
529543 Some(args) => new_args = args,
530544 None => new_args = vec::from_elem(arity, wild())
531545 }
532- Some(vec::append(new_args, vec::tail(r )))
546+ Some(vec::append(new_args, vec::from_slice(r.tail() )))
533547 }
534548 _ => None
535549 }
@@ -545,7 +559,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
545559 _ => wild()
546560 }
547561 });
548- Some(vec::append(args, vec::tail(r )))
562+ Some(vec::append(args, vec::from_slice(r.tail() )))
549563 }
550564 pat_struct(_, ref flds, _) => {
551565 // Is this a struct or an enum variant?
@@ -560,7 +574,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
560574 _ => wild()
561575 }
562576 });
563- Some(vec::append(args, vec::tail(r )))
577+ Some(vec::append(args, vec::from_slice(r.tail() )))
564578 } else {
565579 None
566580 }
@@ -587,13 +601,14 @@ pub fn specialize(cx: @MatchCheckCtxt,
587601 _ => wild()
588602 }
589603 });
590- Some(vec::append(args, vec::tail(r )))
604+ Some(vec::append(args, vec::from_slice(r.tail() )))
591605 }
592606 }
593607 }
594- pat_tup(args) => Some(vec::append(args, vec::tail(r))),
595- pat_box(a) | pat_uniq(a) | pat_region(a) =>
596- Some(vec::append(~[a], vec::tail(r))),
608+ pat_tup(args) => Some(vec::append(args, r.tail())),
609+ pat_box(a) | pat_uniq(a) | pat_region(a) => {
610+ Some(vec::append(~[a], r.tail()))
611+ }
597612 pat_lit(expr) => {
598613 let e_v = eval_const_expr(cx.tcx, expr);
599614 let match_ = match ctor_id {
@@ -605,21 +620,21 @@ pub fn specialize(cx: @MatchCheckCtxt,
605620 single => true,
606621 _ => fail!(~" type error")
607622 };
608- if match_ { Some(vec::tail(r )) } else { None }
623+ if match_ { Some(vec::from_slice(r.tail() )) } else { None }
609624 }
610625 pat_range(lo, hi) => {
611626 let (c_lo, c_hi) = match ctor_id {
612627 val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
613628 range(ref lo, ref hi) =>
614629 ((/*bad*/copy *lo), (/*bad*/copy *hi)),
615- single => return Some(vec::tail(r )),
630+ single => return Some(vec::from_slice(r.tail() )),
616631 _ => fail!(~" type error")
617632 };
618633 let v_lo = eval_const_expr(cx.tcx, lo),
619634 v_hi = eval_const_expr(cx.tcx, hi);
620635 let match_ = compare_const_vals(c_lo, v_lo) >= 0 &&
621636 compare_const_vals(c_hi, v_hi) <= 0;
622- if match_ { Some(vec::tail(r )) } else { None }
637+ if match_ { Some(vec::from_slice(r.tail() )) } else { None }
623638 }
624639 pat_vec(elems, tail) => {
625640 match ctor_id {
@@ -630,10 +645,10 @@ pub fn specialize(cx: @MatchCheckCtxt,
630645 vec::append(elems, vec::from_elem(
631646 arity - num_elements, wild()
632647 )),
633- vec::tail(r )
648+ vec::from_slice(r.tail() )
634649 ))
635650 } else if num_elements == arity {
636- Some(vec::append(elems, vec:: tail(r )))
651+ Some(vec::append(elems, r. tail()))
637652 } else {
638653 None
639654 }
@@ -645,8 +660,8 @@ pub fn specialize(cx: @MatchCheckCtxt,
645660 }
646661}
647662
648- pub fn default(cx: @MatchCheckCtxt, r: ~ [@pat]) -> Option<~[@pat]> {
649- if is_wild(cx, r[0]) { Some(vec::tail(r )) }
663+ pub fn default(cx: @MatchCheckCtxt, r: & [@pat]) -> Option<~[@pat]> {
664+ if is_wild(cx, r[0]) { Some(vec::from_slice(r.tail() )) }
650665 else { None }
651666}
652667
0 commit comments