@@ -74,12 +74,12 @@ impl fmt::Show for Matrix {
74
74
}
75
75
}
76
76
77
- struct MatchCheckCtxt < ' a > {
78
- tcx : & ' a ty:: ctxt
77
+ pub struct MatchCheckCtxt < ' a > {
78
+ pub tcx : & ' a ty:: ctxt
79
79
}
80
80
81
81
#[ deriving( Clone , PartialEq ) ]
82
- enum Constructor {
82
+ pub enum Constructor {
83
83
/// The constructor of all patterns that don't vary by constructor,
84
84
/// e.g. struct patterns and fixed-length arrays.
85
85
Single ,
@@ -492,9 +492,9 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix, v: &[Gc<P
492
492
ctor : Constructor , lty : ty:: t , witness : WitnessPreference ) -> Usefulness {
493
493
let arity = constructor_arity ( cx, & ctor, lty) ;
494
494
let matrix = Matrix ( m. iter ( ) . filter_map ( |r| {
495
- specialize ( cx, r. as_slice ( ) , & ctor, arity)
495
+ specialize ( cx, r. as_slice ( ) , & ctor, 0 u , arity)
496
496
} ) . collect ( ) ) ;
497
- match specialize ( cx, v, & ctor, arity) {
497
+ match specialize ( cx, v, & ctor, 0 u , arity) {
498
498
Some ( v) => is_useful ( cx, & matrix, v. as_slice ( ) , witness) ,
499
499
None => NotUseful
500
500
}
@@ -580,7 +580,7 @@ fn is_wild(cx: &MatchCheckCtxt, p: Gc<Pat>) -> bool {
580
580
///
581
581
/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
582
582
/// A struct pattern's arity is the number of fields it contains, etc.
583
- fn constructor_arity ( cx : & MatchCheckCtxt , ctor : & Constructor , ty : ty:: t ) -> uint {
583
+ pub fn constructor_arity ( cx : & MatchCheckCtxt , ctor : & Constructor , ty : ty:: t ) -> uint {
584
584
match ty:: get ( ty) . sty {
585
585
ty:: ty_tup( ref fs) => fs. len ( ) ,
586
586
ty:: ty_box( _) | ty:: ty_uniq( _) => 1 u,
@@ -628,11 +628,11 @@ fn range_covered_by_constructor(ctor: &Constructor,
628
628
/// different patterns.
629
629
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
630
630
/// fields filled with wild patterns.
631
- fn specialize ( cx : & MatchCheckCtxt , r : & [ Gc < Pat > ] ,
632
- constructor : & Constructor , arity : uint ) -> Option < Vec < Gc < Pat > > > {
631
+ pub fn specialize ( cx : & MatchCheckCtxt , r : & [ Gc < Pat > ] ,
632
+ constructor : & Constructor , col : uint , arity : uint ) -> Option < Vec < Gc < Pat > > > {
633
633
let & Pat {
634
634
id : pat_id, node : ref node, span : pat_span
635
- } = & ( * raw_pat ( r[ 0 ] ) ) ;
635
+ } = & ( * raw_pat ( r[ col ] ) ) ;
636
636
let head: Option < Vec < Gc < Pat > > > = match node {
637
637
& PatWild =>
638
638
Some ( Vec :: from_elem ( arity, wild ( ) ) ) ,
@@ -776,7 +776,7 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
776
776
None
777
777
}
778
778
} ;
779
- head. map ( |head| head. append ( r. tail ( ) ) )
779
+ head. map ( |head| head. append ( r. slice_to ( col ) ) . append ( r . slice_from ( col + 1 ) ) )
780
780
}
781
781
782
782
fn default ( cx : & MatchCheckCtxt , r : & [ Gc < Pat > ] ) -> Option < Vec < Gc < Pat > > > {
0 commit comments