@@ -339,20 +339,20 @@ fn check_arms(cx: &MatchCheckCtxt,
339339 // `Some(<head>)` and `None`. It's impossible to have an unreachable
340340 // pattern
341341 // (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" )
343343 } ,
344344
345345 hir:: MatchSource :: Normal => {
346346 span_err ! ( cx. tcx. sess, pat. span, E0001 , "unreachable pattern" )
347347 } ,
348348
349349 hir:: MatchSource :: TryDesugar => {
350- cx . tcx . sess . span_bug ( pat. span , "unreachable try pattern" )
350+ span_bug ! ( pat. span, "unreachable try pattern" )
351351 } ,
352352 }
353353 }
354354 Useful => ( ) ,
355- UsefulWithWitness ( _) => unreachable ! ( )
355+ UsefulWithWitness ( _) => bug ! ( )
356356 }
357357 if guard. is_none ( ) {
358358 let Matrix ( mut rows) = seen;
@@ -384,9 +384,9 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
384384 let witness = match witnesses[ 0 ] . node {
385385 PatKind :: TupleStruct ( _, Some ( ref pats) ) => match & pats[ ..] {
386386 [ ref pat] => & * * pat,
387- _ => unreachable ! ( ) ,
387+ _ => bug ! ( ) ,
388388 } ,
389- _ => unreachable ! ( ) ,
389+ _ => bug ! ( ) ,
390390 } ;
391391 span_err ! ( cx. tcx. sess, sp, E0297 ,
392392 "refutable pattern in `for` loop binding: \
@@ -399,7 +399,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
399399 } ) . collect ( ) ;
400400 const LIMIT : usize = 3 ;
401401 let joined_patterns = match pattern_strings. len ( ) {
402- 0 => unreachable ! ( ) ,
402+ 0 => bug ! ( ) ,
403403 1 => format ! ( "`{}`" , pattern_strings[ 0 ] ) ,
404404 2 ...LIMIT => {
405405 let ( tail, head) = pattern_strings. split_last ( ) . unwrap ( ) ;
@@ -420,14 +420,14 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
420420 NotUseful => {
421421 // This is good, wildcard pattern isn't reachable
422422 } ,
423- _ => unreachable ! ( )
423+ _ => bug ! ( )
424424 }
425425}
426426
427427fn const_val_to_expr ( value : & ConstVal ) -> P < hir:: Expr > {
428428 let node = match value {
429429 & ConstVal :: Bool ( b) => ast:: LitKind :: Bool ( b) ,
430- _ => unreachable ! ( )
430+ _ => bug ! ( )
431431 } ;
432432 P ( hir:: Expr {
433433 id : 0 ,
@@ -579,14 +579,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
579579 assert_eq ! ( pats_len, n) ;
580580 PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
581581 } ,
582- _ => unreachable ! ( )
582+ _ => bug ! ( )
583583 } ,
584584 ty:: TySlice ( _) => match ctor {
585585 & Slice ( n) => {
586586 assert_eq ! ( pats_len, n) ;
587587 PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
588588 } ,
589- _ => unreachable ! ( )
589+ _ => bug ! ( )
590590 } ,
591591 ty:: TyStr => PatKind :: Wild ,
592592
@@ -791,17 +791,16 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
791791 PatKind :: Struct ( ..) | PatKind :: TupleStruct ( ..) | PatKind :: Path ( ..) | PatKind :: Ident ( ..) =>
792792 match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . unwrap ( ) . full_def ( ) {
793793 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") ,
796796 Def :: Struct ( ..) | Def :: TyAlias ( ..) => vec ! [ Single ] ,
797797 Def :: Variant ( _, id) => vec ! [ Variant ( id) ] ,
798798 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) ,
801801 } ,
802802 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" ) ,
805804 PatKind :: Lit ( ref expr) =>
806805 vec ! ( ConstantValue ( eval_const_expr( cx. tcx, & expr) ) ) ,
807806 PatKind :: Range ( ref lo, ref hi) =>
@@ -837,7 +836,7 @@ pub fn constructor_arity(_cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> us
837836 ty:: TySlice ( _) => match * ctor {
838837 Slice ( length) => length,
839838 ConstantValue ( _) => 0 ,
840- _ => unreachable ! ( )
839+ _ => bug ! ( )
841840 } ,
842841 ty:: TyStr => 0 ,
843842 _ => 1
@@ -856,7 +855,7 @@ fn range_covered_by_constructor(ctor: &Constructor,
856855 ConstantValue ( ref value) => ( value, value) ,
857856 ConstantRange ( ref from, ref to) => ( from, to) ,
858857 Single => return Some ( true ) ,
859- _ => unreachable ! ( )
858+ _ => bug ! ( )
860859 } ;
861860 let cmp_from = compare_const_vals ( c_from, from) ;
862861 let cmp_to = compare_const_vals ( c_to, to) ;
@@ -889,22 +888,22 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
889888 let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
890889 match def {
891890 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") ,
894893 Def :: Variant ( _, id) if * constructor != Variant ( id) => None ,
895894 Def :: Variant ( ..) | Def :: Struct ( ..) => Some ( Vec :: new ( ) ) ,
896895 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) ,
899898 }
900899 }
901900
902901 PatKind :: TupleStruct ( _, ref args) => {
903902 let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
904903 match def {
905904 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") ,
908907 Def :: Variant ( _, id) if * constructor != Variant ( id) => None ,
909908 Def :: Variant ( ..) | Def :: Struct ( ..) => {
910909 Some ( match args {
@@ -917,8 +916,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
917916 }
918917
919918 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" )
922920 }
923921
924922 PatKind :: Struct ( _, ref pattern_fields, _) => {
@@ -1062,7 +1060,7 @@ fn is_refutable<A, F>(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option<A>
10621060 match is_useful ( cx, & pats, & [ DUMMY_WILD_PAT ] , ConstructWitness ) {
10631061 UsefulWithWitness ( pats) => Some ( refutable ( & pats[ 0 ] ) ) ,
10641062 NotUseful => None ,
1065- Useful => unreachable ! ( )
1063+ Useful => bug ! ( )
10661064 }
10671065}
10681066
@@ -1119,12 +1117,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
11191117 PatKind :: Ident ( hir:: BindByRef ( _) , _, _) => {
11201118 }
11211119 _ => {
1122- cx . tcx . sess . span_bug (
1120+ span_bug ! (
11231121 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) ;
11281125 }
11291126 }
11301127 }
0 commit comments