@@ -549,10 +549,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
549
549
}
550
550
551
551
hir:: PatKind :: Slice ( ref prefix, ref slice, ref suffix) => {
552
- match ty. kind {
553
- ty:: Slice ( ..) | ty:: Array ( ..) => { }
554
- _ => span_bug ! ( pat. span, "unexpanded type for vector pattern: {:?}" , ty) ,
555
- }
556
552
self . slice_or_array_pattern ( pat. span , ty, prefix, slice, suffix)
557
553
}
558
554
@@ -658,44 +654,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
658
654
pats. iter ( ) . map ( |p| self . lower_pattern ( p) ) . collect ( )
659
655
}
660
656
661
- fn lower_opt_pattern ( & mut self , pat : & ' tcx Option < P < hir:: Pat > > ) -> Option < Pat < ' tcx > >
662
- {
657
+ fn lower_opt_pattern ( & mut self , pat : & ' tcx Option < P < hir:: Pat > > ) -> Option < Pat < ' tcx > > {
663
658
pat. as_ref ( ) . map ( |p| self . lower_pattern ( p) )
664
659
}
665
660
666
- fn flatten_nested_slice_patterns (
667
- & mut self ,
668
- prefix : Vec < Pat < ' tcx > > ,
669
- slice : Option < Pat < ' tcx > > ,
670
- suffix : Vec < Pat < ' tcx > > ,
671
- ) -> ( Vec < Pat < ' tcx > > , Option < Pat < ' tcx > > , Vec < Pat < ' tcx > > ) {
672
- let orig_slice = match slice {
673
- Some ( orig_slice) => orig_slice,
674
- None => return ( prefix, slice, suffix)
675
- } ;
676
- let orig_prefix = prefix;
677
- let orig_suffix = suffix;
678
-
679
- // dance because of intentional borrow-checker stupidity.
680
- let kind = * orig_slice. kind ;
681
- match kind {
682
- PatKind :: Slice { prefix, slice, mut suffix } |
683
- PatKind :: Array { prefix, slice, mut suffix } => {
684
- let mut orig_prefix = orig_prefix;
685
-
686
- orig_prefix. extend ( prefix) ;
687
- suffix. extend ( orig_suffix) ;
688
-
689
- ( orig_prefix, slice, suffix)
690
- }
691
- _ => {
692
- ( orig_prefix, Some ( Pat {
693
- kind : box kind, ..orig_slice
694
- } ) , orig_suffix)
695
- }
696
- }
697
- }
698
-
699
661
fn slice_or_array_pattern (
700
662
& mut self ,
701
663
span : Span ,
@@ -707,9 +669,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
707
669
let prefix = self . lower_patterns ( prefix) ;
708
670
let slice = self . lower_opt_pattern ( slice) ;
709
671
let suffix = self . lower_patterns ( suffix) ;
710
- let ( prefix, slice, suffix) = self . flatten_nested_slice_patterns ( prefix, slice, suffix) ;
711
-
712
- // Some validation:
713
672
match ty. kind {
714
673
// Matching a slice, `[T]`.
715
674
ty:: Slice ( ..) => PatKind :: Slice { prefix, slice, suffix } ,
0 commit comments