@@ -50,7 +50,9 @@ pub(crate) enum PatKind<'tcx> {
50
50
51
51
Slice {
52
52
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 ,
54
56
suffix : Box < [ Box < Pat < ' tcx > > ] > ,
55
57
} ,
56
58
@@ -68,8 +70,8 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
68
70
PatKind :: Deref { ref subpattern } => write_ref_like ( f, self . ty , subpattern) ,
69
71
PatKind :: Constant { value } => write ! ( f, "{value}" ) ,
70
72
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)
73
75
}
74
76
}
75
77
}
@@ -194,21 +196,16 @@ fn write_ref_like<'tcx>(
194
196
fn write_slice_like < ' tcx > (
195
197
f : & mut impl fmt:: Write ,
196
198
prefix : & [ Box < Pat < ' tcx > > ] ,
197
- slice : & Option < Box < Pat < ' tcx > > > ,
199
+ has_dot_dot : bool ,
198
200
suffix : & [ Box < Pat < ' tcx > > ] ,
199
201
) -> fmt:: Result {
200
202
let mut start_or_comma = start_or_comma ( ) ;
201
203
write ! ( f, "[" ) ?;
202
204
for p in prefix. iter ( ) {
203
205
write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
204
206
}
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( ) ) ?;
212
209
}
213
210
for p in suffix. iter ( ) {
214
211
write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
0 commit comments