@@ -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 {
@@ -310,7 +311,7 @@ fn all_constructors(cx: &MatchCheckCtxt, m: &Matrix, left_ty: ty::t) -> Vec<ctor
310
311
ty:: ty_enum( eid, _) =>
311
312
ty:: enum_variants ( cx. tcx , eid)
312
313
. iter ( )
313
- . map ( |va| variant ( va. id , va . arg_names . is_some ( ) ) )
314
+ . map ( |va| variant ( va. id ) )
314
315
. collect ( ) ,
315
316
316
317
ty:: ty_vec( _, None ) =>
@@ -434,7 +435,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, left_ty: ty::t, p: Gc<Pat>) -> Option<ctor>
434
435
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
435
436
Some ( val ( eval_const_expr ( cx. tcx , & * const_expr) ) )
436
437
} ,
437
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
438
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
438
439
_ => None
439
440
} ,
440
441
PatEnum ( ..) =>
@@ -443,12 +444,12 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, left_ty: ty::t, p: Gc<Pat>) -> Option<ctor>
443
444
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
444
445
Some ( val ( eval_const_expr ( cx. tcx , & * const_expr) ) )
445
446
} ,
446
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
447
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
447
448
_ => Some ( single)
448
449
} ,
449
450
PatStruct ( ..) =>
450
451
match cx. tcx . def_map . borrow ( ) . find ( & pat. id ) {
451
- Some ( & DefVariant ( _, id, is_structure ) ) => Some ( variant ( id, is_structure ) ) ,
452
+ Some ( & DefVariant ( _, id, _ ) ) => Some ( variant ( id) ) ,
452
453
_ => Some ( single)
453
454
} ,
454
455
PatLit ( expr) =>
@@ -498,7 +499,7 @@ fn constructor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
498
499
} ,
499
500
ty:: ty_enum( eid, _) => {
500
501
match * ctor {
501
- variant( id, _ ) => enum_variant_with_id ( cx. tcx , eid, id) . args . len ( ) ,
502
+ variant( id) => enum_variant_with_id ( cx. tcx , eid, id) . args . len ( ) ,
502
503
_ => unreachable ! ( )
503
504
}
504
505
}
@@ -545,9 +546,10 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
545
546
& PatIdent ( _, _, _) => {
546
547
let opt_def = cx. tcx . def_map . borrow ( ) . find_copy ( pat_id) ;
547
548
match opt_def {
548
- Some ( DefVariant ( _, id, _) ) => match * ctor_id {
549
- variant( vid, _) if vid == id => Some ( vec ! ( ) ) ,
550
- _ => None
549
+ Some ( DefVariant ( _, id, _) ) => if * ctor_id == variant ( id) {
550
+ Some ( vec ! ( ) )
551
+ } else {
552
+ None
551
553
} ,
552
554
Some ( DefStatic ( did, _) ) => {
553
555
let const_expr = lookup_const_by_id ( cx. tcx , did) . unwrap ( ) ;
@@ -581,7 +583,7 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
581
583
}
582
584
}
583
585
}
584
- DefVariant ( _, id, _) if variant ( id , false ) != * ctor_id => None ,
586
+ DefVariant ( _, id, _) if * ctor_id != variant ( id ) => None ,
585
587
DefVariant ( ..) | DefFn ( ..) | DefStruct ( ..) => {
586
588
Some ( match args {
587
589
& Some ( ref args) => args. clone ( ) ,
@@ -596,7 +598,7 @@ fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
596
598
// Is this a struct or an enum variant?
597
599
let def = cx. tcx . def_map . borrow ( ) . get_copy ( pat_id) ;
598
600
let class_id = match def {
599
- DefVariant ( _, variant_id, _) => if * ctor_id == variant ( variant_id, true ) {
601
+ DefVariant ( _, variant_id, _) => if * ctor_id == variant ( variant_id) {
600
602
Some ( variant_id)
601
603
} else {
602
604
None
0 commit comments