@@ -351,38 +351,15 @@ impl<'tcx> Witness<'tcx> {
351
351
ty : Ty < ' tcx > )
352
352
-> Self
353
353
{
354
- // If we've been trying to exhaustively match over the domain of values for a type,
355
- // then we can construct witnesses directly corresponding to the missing ranges of values,
356
- // giving far more precise diagnostics.
357
- // `ConstantValue` and `ConstantRange` only occur in practice when doing exhaustive value
358
- // matching (exhaustive_integer_patterns).
359
- match ctor {
360
- ConstantValue ( value) => {
361
- Witness ( vec ! [ Pattern {
362
- ty,
363
- span: DUMMY_SP ,
364
- kind: box PatternKind :: Constant { value } ,
365
- } ] )
366
- }
367
- ConstantRange ( lo, hi, end) => {
368
- Witness ( vec ! [ Pattern {
369
- ty,
370
- span: DUMMY_SP ,
371
- kind: box PatternKind :: Range { lo, hi, end: * end } ,
372
- } ] )
354
+ let sub_pattern_tys = constructor_sub_pattern_tys ( cx, ctor, ty) ;
355
+ self . 0 . extend ( sub_pattern_tys. into_iter ( ) . map ( |ty| {
356
+ Pattern {
357
+ ty,
358
+ span : DUMMY_SP ,
359
+ kind : box PatternKind :: Wild ,
373
360
}
374
- _ => {
375
- let sub_pattern_tys = constructor_sub_pattern_tys ( cx, ctor, ty) ;
376
- self . 0 . extend ( sub_pattern_tys. into_iter ( ) . map ( |ty| {
377
- Pattern {
378
- ty,
379
- span : DUMMY_SP ,
380
- kind : box PatternKind :: Wild ,
381
- }
382
- } ) ) ;
383
- self . apply_constructor ( cx, ctor, ty)
384
- }
385
- }
361
+ } ) ) ;
362
+ self . apply_constructor ( cx, ctor, ty)
386
363
}
387
364
388
365
@@ -409,7 +386,7 @@ impl<'tcx> Witness<'tcx> {
409
386
let arity = constructor_arity ( cx, ctor, ty) ;
410
387
let pat = {
411
388
let len = self . 0 . len ( ) as u64 ;
412
- let mut pats = self . 0 . drain ( ( len- arity) as usize ..) . rev ( ) ;
389
+ let mut pats = self . 0 . drain ( ( len - arity) as usize ..) . rev ( ) ;
413
390
414
391
match ty. sty {
415
392
ty:: TyAdt ( ..) |
@@ -452,6 +429,7 @@ impl<'tcx> Witness<'tcx> {
452
429
_ => {
453
430
match * ctor {
454
431
ConstantValue ( value) => PatternKind :: Constant { value } ,
432
+ ConstantRange ( lo, hi, end) => PatternKind :: Range { lo, hi, end } ,
455
433
_ => PatternKind :: Wild ,
456
434
}
457
435
}
0 commit comments