@@ -328,7 +328,7 @@ impl Constructor {
328
328
PatKind :: Leaf { .. } | PatKind :: Deref { .. } => Single ,
329
329
& PatKind :: Variant { enum_variant, .. } => Variant ( enum_variant) ,
330
330
& PatKind :: LiteralBool { value } => IntRange ( IntRange :: from_bool ( value) ) ,
331
- PatKind :: Or { .. } => panic ! ( "bug: Or-pattern should have been expanded earlier on.") ,
331
+ PatKind :: Or { .. } => cx . bug ( " Or-pattern should have been expanded earlier on.") ,
332
332
}
333
333
}
334
334
@@ -375,7 +375,7 @@ impl Constructor {
375
375
/// this checks for inclusion.
376
376
// We inline because this has a single call site in `Matrix::specialize_constructor`.
377
377
#[ inline]
378
- pub ( super ) fn is_covered_by ( & self , _pcx : PatCtxt < ' _ > , other : & Self ) -> bool {
378
+ pub ( super ) fn is_covered_by ( & self , pcx : PatCtxt < ' _ > , other : & Self ) -> bool {
379
379
// This must be kept in sync with `is_covered_by_any`.
380
380
match ( self , other) {
381
381
// Wildcards cover anything
@@ -400,17 +400,17 @@ impl Constructor {
400
400
// Only a wildcard pattern can match the special extra constructor.
401
401
( NonExhaustive , _) => false ,
402
402
403
- _ => panic ! (
404
- "bug: trying to compare incompatible constructors {:?} and {:?}" ,
403
+ _ => pcx . cx . bug ( & format ! (
404
+ "trying to compare incompatible constructors {:?} and {:?}" ,
405
405
self , other
406
- ) ,
406
+ ) ) ,
407
407
}
408
408
}
409
409
410
410
/// Faster version of `is_covered_by` when applied to many constructors. `used_ctors` is
411
411
/// assumed to be built from `matrix.head_ctors()` with wildcards filtered out, and `self` is
412
412
/// assumed to have been split from a wildcard.
413
- fn is_covered_by_any ( & self , _pcx : PatCtxt < ' _ > , used_ctors : & [ Constructor ] ) -> bool {
413
+ fn is_covered_by_any ( & self , pcx : PatCtxt < ' _ > , used_ctors : & [ Constructor ] ) -> bool {
414
414
if used_ctors. is_empty ( ) {
415
415
return false ;
416
416
}
@@ -431,7 +431,7 @@ impl Constructor {
431
431
// This constructor is never covered by anything else
432
432
NonExhaustive => false ,
433
433
Str ( ..) | FloatRange ( ..) | Opaque | Missing | Wildcard => {
434
- panic ! ( "bug: found unexpected ctor in all_ctors: {:?}" , self )
434
+ pcx . cx . bug ( & format ! ( "found unexpected ctor in all_ctors: {:?}" , self ) )
435
435
}
436
436
}
437
437
}
@@ -683,7 +683,9 @@ impl Fields {
683
683
}
684
684
}
685
685
}
686
- _ => panic ! ( "Unexpected type for `Single` constructor: {:?}" , ty) ,
686
+ ty_kind => {
687
+ cx. bug ( & format ! ( "Unexpected type for `Single` constructor: {:?}" , ty_kind) )
688
+ }
687
689
} ,
688
690
Slice ( ..) => {
689
691
unimplemented ! ( )
@@ -748,7 +750,7 @@ impl Fields {
748
750
// can ignore this issue.
749
751
TyKind :: Ref ( ..) => PatKind :: Deref { subpattern : subpatterns. next ( ) . unwrap ( ) } ,
750
752
TyKind :: Slice ( ..) | TyKind :: Array ( ..) => {
751
- panic ! ( "bug: bad slice pattern {:?} {:?}" , ctor, pcx. ty)
753
+ pcx . cx . bug ( & format ! ( "bad slice pattern {:?} {:?}" , ctor, pcx. ty) )
752
754
}
753
755
_ => PatKind :: Wild ,
754
756
} ,
@@ -758,10 +760,11 @@ impl Fields {
758
760
Constructor :: IntRange ( _) => UNHANDLED ,
759
761
NonExhaustive => PatKind :: Wild ,
760
762
Wildcard => return Pat :: wildcard_from_ty ( pcx. ty ) ,
761
- Opaque => panic ! ( "bug: we should not try to apply an opaque constructor" ) ,
762
- Missing => {
763
- panic ! ( "bug: trying to apply the `Missing` constructor; this should have been done in `apply_constructors`" )
764
- }
763
+ Opaque => pcx. cx . bug ( "we should not try to apply an opaque constructor" ) ,
764
+ Missing => pcx. cx . bug (
765
+ "trying to apply the `Missing` constructor;\
766
+ this should have been done in `apply_constructors`",
767
+ ) ,
765
768
} ;
766
769
767
770
Pat { ty : pcx. ty . clone ( ) , kind : Box :: new ( pat) }
0 commit comments