@@ -50,7 +50,9 @@ pub(crate) enum PatKind<'tcx> {
5050
5151 Slice {
5252 prefix : Box < [ Box < Pat < ' tcx > > ] > ,
53- slice : Option < Box < Pat < ' tcx > > > ,
53+ /// True if this slice-like pattern should include a `..` between the
54+ /// prefix and suffix.
55+ has_dot_dot : bool ,
5456 suffix : Box < [ Box < Pat < ' tcx > > ] > ,
5557 } ,
5658
@@ -68,8 +70,8 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
6870 PatKind :: Deref { ref subpattern } => write_ref_like ( f, self . ty , subpattern) ,
6971 PatKind :: Constant { value } => write ! ( f, "{value}" ) ,
7072 PatKind :: Range ( ref range) => write ! ( f, "{range}" ) ,
71- PatKind :: Slice { ref prefix, ref slice , ref suffix } => {
72- write_slice_like ( f, prefix, slice , suffix)
73+ PatKind :: Slice { ref prefix, has_dot_dot , ref suffix } => {
74+ write_slice_like ( f, prefix, has_dot_dot , suffix)
7375 }
7476 }
7577 }
@@ -194,21 +196,16 @@ fn write_ref_like<'tcx>(
194196fn write_slice_like < ' tcx > (
195197 f : & mut impl fmt:: Write ,
196198 prefix : & [ Box < Pat < ' tcx > > ] ,
197- slice : & Option < Box < Pat < ' tcx > > > ,
199+ has_dot_dot : bool ,
198200 suffix : & [ Box < Pat < ' tcx > > ] ,
199201) -> fmt:: Result {
200202 let mut start_or_comma = start_or_comma ( ) ;
201203 write ! ( f, "[" ) ?;
202204 for p in prefix. iter ( ) {
203205 write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
204206 }
205- if let Some ( ref slice) = * slice {
206- write ! ( f, "{}" , start_or_comma( ) ) ?;
207- match slice. kind {
208- PatKind :: Wild => { }
209- _ => write ! ( f, "{slice}" ) ?,
210- }
211- write ! ( f, ".." ) ?;
207+ if has_dot_dot {
208+ write ! ( f, "{}.." , start_or_comma( ) ) ?;
212209 }
213210 for p in suffix. iter ( ) {
214211 write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
0 commit comments