@@ -339,20 +339,20 @@ fn check_arms(cx: &MatchCheckCtxt,
339
339
// `Some(<head>)` and `None`. It's impossible to have an unreachable
340
340
// pattern
341
341
// (see libsyntax/ext/expand.rs for the full expansion of a for loop)
342
- cx . tcx . sess . span_bug ( pat. span , "unreachable for-loop pattern" )
342
+ span_bug ! ( pat. span, "unreachable for-loop pattern" )
343
343
} ,
344
344
345
345
hir:: MatchSource :: Normal => {
346
346
span_err ! ( cx. tcx. sess, pat. span, E0001 , "unreachable pattern" )
347
347
} ,
348
348
349
349
hir:: MatchSource :: TryDesugar => {
350
- cx . tcx . sess . span_bug ( pat. span , "unreachable try pattern" )
350
+ span_bug ! ( pat. span, "unreachable try pattern" )
351
351
} ,
352
352
}
353
353
}
354
354
Useful => ( ) ,
355
- UsefulWithWitness ( _) => unreachable ! ( )
355
+ UsefulWithWitness ( _) => bug ! ( )
356
356
}
357
357
if guard. is_none ( ) {
358
358
let Matrix ( mut rows) = seen;
@@ -384,9 +384,9 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
384
384
let witness = match witnesses[ 0 ] . node {
385
385
PatKind :: TupleStruct ( _, Some ( ref pats) ) => match & pats[ ..] {
386
386
[ ref pat] => & * * pat,
387
- _ => unreachable ! ( ) ,
387
+ _ => bug ! ( ) ,
388
388
} ,
389
- _ => unreachable ! ( ) ,
389
+ _ => bug ! ( ) ,
390
390
} ;
391
391
span_err ! ( cx. tcx. sess, sp, E0297 ,
392
392
"refutable pattern in `for` loop binding: \
@@ -399,7 +399,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
399
399
} ) . collect ( ) ;
400
400
const LIMIT : usize = 3 ;
401
401
let joined_patterns = match pattern_strings. len ( ) {
402
- 0 => unreachable ! ( ) ,
402
+ 0 => bug ! ( ) ,
403
403
1 => format ! ( "`{}`" , pattern_strings[ 0 ] ) ,
404
404
2 ...LIMIT => {
405
405
let ( tail, head) = pattern_strings. split_last ( ) . unwrap ( ) ;
@@ -420,14 +420,14 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
420
420
NotUseful => {
421
421
// This is good, wildcard pattern isn't reachable
422
422
} ,
423
- _ => unreachable ! ( )
423
+ _ => bug ! ( )
424
424
}
425
425
}
426
426
427
427
fn const_val_to_expr ( value : & ConstVal ) -> P < hir:: Expr > {
428
428
let node = match value {
429
429
& ConstVal :: Bool ( b) => ast:: LitKind :: Bool ( b) ,
430
- _ => unreachable ! ( )
430
+ _ => bug ! ( )
431
431
} ;
432
432
P ( hir:: Expr {
433
433
id : 0 ,
@@ -579,14 +579,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
579
579
assert_eq ! ( pats_len, n) ;
580
580
PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
581
581
} ,
582
- _ => unreachable ! ( )
582
+ _ => bug ! ( )
583
583
} ,
584
584
ty:: TySlice ( _) => match ctor {
585
585
& Slice ( n) => {
586
586
assert_eq ! ( pats_len, n) ;
587
587
PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
588
588
} ,
589
- _ => unreachable ! ( )
589
+ _ => bug ! ( )
590
590
} ,
591
591
ty:: TyStr => PatKind :: Wild ,
592
592
@@ -791,17 +791,16 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
791
791
PatKind :: Struct ( ..) | PatKind :: TupleStruct ( ..) | PatKind :: Path ( ..) | PatKind :: Ident ( ..) =>
792
792
match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . unwrap ( ) . full_def ( ) {
793
793
Def :: Const ( ..) | Def :: AssociatedConst ( ..) =>
794
- cx . tcx . sess . span_bug ( pat. span , "const pattern should've \
795
- been rewritten") ,
794
+ span_bug ! ( pat. span, "const pattern should've \
795
+ been rewritten") ,
796
796
Def :: Struct ( ..) | Def :: TyAlias ( ..) => vec ! [ Single ] ,
797
797
Def :: Variant ( _, id) => vec ! [ Variant ( id) ] ,
798
798
Def :: Local ( ..) => vec ! [ ] ,
799
- def => cx . tcx . sess . span_bug ( pat. span , & format ! ( "pat_constructors: unexpected \
800
- definition {:?}", def) ) ,
799
+ def => span_bug ! ( pat. span, "pat_constructors: unexpected \
800
+ definition {:?}", def) ,
801
801
} ,
802
802
PatKind :: QPath ( ..) =>
803
- cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
804
- been rewritten") ,
803
+ span_bug ! ( pat. span, "const pattern should've been rewritten" ) ,
805
804
PatKind :: Lit ( ref expr) =>
806
805
vec ! ( ConstantValue ( eval_const_expr( cx. tcx, & expr) ) ) ,
807
806
PatKind :: Range ( ref lo, ref hi) =>
@@ -837,7 +836,7 @@ pub fn constructor_arity(_cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> us
837
836
ty:: TySlice ( _) => match * ctor {
838
837
Slice ( length) => length,
839
838
ConstantValue ( _) => 0 ,
840
- _ => unreachable ! ( )
839
+ _ => bug ! ( )
841
840
} ,
842
841
ty:: TyStr => 0 ,
843
842
_ => 1
@@ -856,7 +855,7 @@ fn range_covered_by_constructor(ctor: &Constructor,
856
855
ConstantValue ( ref value) => ( value, value) ,
857
856
ConstantRange ( ref from, ref to) => ( from, to) ,
858
857
Single => return Some ( true ) ,
859
- _ => unreachable ! ( )
858
+ _ => bug ! ( )
860
859
} ;
861
860
let cmp_from = compare_const_vals ( c_from, from) ;
862
861
let cmp_to = compare_const_vals ( c_to, to) ;
@@ -889,22 +888,22 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
889
888
let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
890
889
match def {
891
890
Def :: Const ( ..) | Def :: AssociatedConst ( ..) =>
892
- cx . tcx . sess . span_bug ( pat_span, "const pattern should've \
893
- been rewritten") ,
891
+ span_bug ! ( pat_span, "const pattern should've \
892
+ been rewritten") ,
894
893
Def :: Variant ( _, id) if * constructor != Variant ( id) => None ,
895
894
Def :: Variant ( ..) | Def :: Struct ( ..) => Some ( Vec :: new ( ) ) ,
896
895
Def :: Local ( ..) => Some ( vec ! [ DUMMY_WILD_PAT ; arity] ) ,
897
- _ => cx . tcx . sess . span_bug ( pat_span, & format ! ( "specialize: unexpected \
898
- definition {:?}", def) ) ,
896
+ _ => span_bug ! ( pat_span, "specialize: unexpected \
897
+ definition {:?}", def) ,
899
898
}
900
899
}
901
900
902
901
PatKind :: TupleStruct ( _, ref args) => {
903
902
let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
904
903
match def {
905
904
Def :: Const ( ..) | Def :: AssociatedConst ( ..) =>
906
- cx . tcx . sess . span_bug ( pat_span, "const pattern should've \
907
- been rewritten") ,
905
+ span_bug ! ( pat_span, "const pattern should've \
906
+ been rewritten") ,
908
907
Def :: Variant ( _, id) if * constructor != Variant ( id) => None ,
909
908
Def :: Variant ( ..) | Def :: Struct ( ..) => {
910
909
Some ( match args {
@@ -917,8 +916,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
917
916
}
918
917
919
918
PatKind :: QPath ( _, _) => {
920
- cx. tcx . sess . span_bug ( pat_span, "const pattern should've \
921
- been rewritten")
919
+ span_bug ! ( pat_span, "const pattern should've been rewritten" )
922
920
}
923
921
924
922
PatKind :: Struct ( _, ref pattern_fields, _) => {
@@ -1062,7 +1060,7 @@ fn is_refutable<A, F>(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option<A>
1062
1060
match is_useful ( cx, & pats, & [ DUMMY_WILD_PAT ] , ConstructWitness ) {
1063
1061
UsefulWithWitness ( pats) => Some ( refutable ( & pats[ 0 ] ) ) ,
1064
1062
NotUseful => None ,
1065
- Useful => unreachable ! ( )
1063
+ Useful => bug ! ( )
1066
1064
}
1067
1065
}
1068
1066
@@ -1119,12 +1117,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
1119
1117
PatKind :: Ident ( hir:: BindByRef ( _) , _, _) => {
1120
1118
}
1121
1119
_ => {
1122
- cx . tcx . sess . span_bug (
1120
+ span_bug ! (
1123
1121
p. span,
1124
- & format ! ( "binding pattern {} is not an \
1125
- identifier: {:?}",
1126
- p. id,
1127
- p. node) ) ;
1122
+ "binding pattern {} is not an identifier: {:?}" ,
1123
+ p. id,
1124
+ p. node) ;
1128
1125
}
1129
1126
}
1130
1127
}
0 commit comments