@@ -194,7 +194,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, m: &Matrix) {
194
194
#[ deriving( Clone , PartialEq ) ]
195
195
enum ctor {
196
196
single,
197
- variant( DefId /* variant */ , bool /* is_structure */ ) ,
197
+ variant( DefId ) ,
198
198
val( const_val ) ,
199
199
range( const_val , const_val ) ,
200
200
vec( uint )
@@ -218,7 +218,8 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &ctor, pats: Vec<Gc<Pat>>, lty:
218
218
219
219
ty:: ty_enum( cid, _) | ty:: ty_struct( cid, _) => {
220
220
let ( vid, is_structure) = match ctor {
221
- & variant( vid, is_structure) => ( vid, is_structure) ,
221
+ & variant( vid) => ( vid,
222
+ ty:: enum_variant_with_id ( cx. tcx , cid, vid) . arg_names . is_some ( ) ) ,
222
223
_ => ( cid, true )
223
224
} ;
224
225
if is_structure {
@@ -316,7 +317,7 @@ fn all_constructors(cx: &MatchCheckCtxt, m: &Matrix, left_ty: ty::t) -> Vec<ctor
316
317
ty:: ty_enum( eid, _) =>
317
318
ty:: enum_variants ( cx. tcx , eid)
318
319
. iter ( )
319
- . map ( |va| variant ( va. id , va . arg_names . is_some ( ) ) )
320
+ . map ( |va| variant ( va. id ) )
320
321
. collect ( ) ,
321
322
322
323
ty:: ty_vec( _, None ) =>
@@ -440,7 +441,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, left_ty: ty::t, p: Gc<Pat>) -> Option<ctor>
440
441
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
441
442
Some ( val ( eval_const_expr ( cx. tcx , & * const_expr) ) )
442
443
} ,
443
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
444
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
444
445
_ => None
445
446
} ,
446
447
PatEnum ( ..) =>
@@ -449,12 +450,12 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, left_ty: ty::t, p: Gc<Pat>) -> Option<ctor>
449
450
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
450
451
Some ( val ( eval_const_expr ( cx. tcx , & * const_expr) ) )
451
452
} ,
452
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
453
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
453
454
_ => Some ( single)
454
455
} ,
455
456
PatStruct ( ..) =>
456
457
match cx. tcx . def_map . borrow ( ) . find ( & pat. id ) {
457
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
458
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
458
459
_ => Some ( single)
459
460
} ,
460
461
PatLit ( expr) =>
@@ -504,7 +505,7 @@ fn constructor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
504
505
} ,
505
506
ty:: ty_enum( eid, _) => {
506
507
match * ctor {
507
- variant( id, _ ) => enum_variant_with_id ( cx. tcx , eid, id) . args . len ( ) ,
508
+ variant( id) => enum_variant_with_id ( cx. tcx , eid, id) . args . len ( ) ,
508
509
_ => unreachable ! ( )
509
510
}
510
511
}
@@ -551,9 +552,10 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
551
552
& PatIdent ( _, _, _) => {
552
553
let opt_def = cx. tcx . def_map . borrow ( ) . find_copy ( pat_id) ;
553
554
match opt_def {
554
- Some ( DefVariant ( _, id, _) ) => match * ctor_id {
555
- variant( vid, _) if vid == id => Some ( vec ! ( ) ) ,
556
- _ => None
555
+ Some ( DefVariant ( _, id, _) ) => if * ctor_id == variant ( id) {
556
+ Some ( vec ! ( ) )
557
+ } else {
558
+ None
557
559
} ,
558
560
Some ( DefStatic ( did, _) ) => {
559
561
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
@@ -587,7 +589,7 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
587
589
}
588
590
}
589
591
}
590
- DefVariant ( _, id, _) if variant ( id , false ) != * ctor_id => None ,
592
+ DefVariant ( _, id, _) if * ctor_id != variant ( id ) => None ,
591
593
DefVariant ( ..) | DefFn ( ..) | DefStruct ( ..) => {
592
594
Some ( match args {
593
595
& Some ( ref args) => args. clone ( ) ,
@@ -602,7 +604,7 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
602
604
// Is this a struct or an enum variant?
603
605
let def = cx. tcx . def_map . borrow ( ) . get_copy ( pat_id) ;
604
606
let class_id = match def {
605
- DefVariant ( _, variant_id, _) => if * ctor_id == variant ( variant_id, true ) {
607
+ DefVariant ( _, variant_id, _) => if * ctor_id == variant ( variant_id) {
606
608
Some ( variant_id)
607
609
} else {
608
610
None
0 commit comments