@@ -337,43 +337,45 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
337
337
/// A row of a matrix. Rows of len 1 are very common, which is why `SmallVec[_; 2]`
338
338
/// works well.
339
339
#[ derive( Debug , Clone ) ]
340
- pub struct PatStack < ' p , ' tcx > ( SmallVec < [ & ' p Pat < ' tcx > ; 2 ] > ) ;
340
+ pub struct PatStack < ' p , ' tcx > {
341
+ patterns : SmallVec < [ & ' p Pat < ' tcx > ; 2 ] > ,
342
+ }
341
343
342
344
impl < ' p , ' tcx > PatStack < ' p , ' tcx > {
343
345
pub fn from_pattern ( pat : & ' p Pat < ' tcx > ) -> Self {
344
- PatStack ( smallvec ! [ pat] )
346
+ PatStack :: from_vec ( smallvec ! [ pat] )
345
347
}
346
348
347
349
fn empty ( ) -> Self {
348
- PatStack ( smallvec ! [ ] )
350
+ PatStack :: from_vec ( smallvec ! [ ] )
349
351
}
350
352
351
353
fn from_vec ( vec : SmallVec < [ & ' p Pat < ' tcx > ; 2 ] > ) -> Self {
352
- PatStack ( vec)
354
+ PatStack { patterns : vec }
353
355
}
354
356
355
357
fn from_slice ( s : & [ & ' p Pat < ' tcx > ] ) -> Self {
356
- PatStack ( SmallVec :: from_slice ( s) )
358
+ PatStack :: from_vec ( SmallVec :: from_slice ( s) )
357
359
}
358
360
359
361
fn is_empty ( & self ) -> bool {
360
- self . 0 . is_empty ( )
362
+ self . patterns . is_empty ( )
361
363
}
362
364
363
365
fn len ( & self ) -> usize {
364
- self . 0 . len ( )
366
+ self . patterns . len ( )
365
367
}
366
368
367
369
fn head < ' a > ( & ' a self ) -> & ' p Pat < ' tcx > {
368
- self . 0 [ 0 ]
370
+ self . patterns [ 0 ]
369
371
}
370
372
371
373
fn head_ctors ( & self , cx : & MatchCheckCtxt < ' _ , ' tcx > ) -> SmallVec < [ Constructor < ' tcx > ; 1 ] > {
372
374
pat_constructors ( cx. tcx , cx. param_env , self . head ( ) )
373
375
}
374
376
375
377
fn iter ( & self ) -> impl Iterator < Item = & Pat < ' tcx > > {
376
- self . 0 . iter ( ) . map ( |p| * p)
378
+ self . patterns . iter ( ) . map ( |p| * p)
377
379
}
378
380
379
381
/// This computes `S(constructor, self)`. See top of the file for explanations.
@@ -391,7 +393,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
391
393
let result = new_heads
392
394
. into_iter ( )
393
395
. map ( |mut new_head| {
394
- new_head. 0 . extend_from_slice ( & self . 0 [ 1 ..] ) ;
396
+ new_head. patterns . extend_from_slice ( & self . patterns [ 1 ..] ) ;
395
397
new_head
396
398
} )
397
399
. collect ( ) ;
@@ -402,7 +404,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
402
404
403
405
impl < ' p , ' tcx > Default for PatStack < ' p , ' tcx > {
404
406
fn default ( ) -> Self {
405
- PatStack ( smallvec ! [ ] )
407
+ PatStack :: empty ( )
406
408
}
407
409
}
408
410
@@ -411,7 +413,7 @@ impl<'p, 'tcx> FromIterator<&'p Pat<'tcx>> for PatStack<'p, 'tcx> {
411
413
where
412
414
T : IntoIterator < Item = & ' p Pat < ' tcx > > ,
413
415
{
414
- PatStack ( iter. into_iter ( ) . collect ( ) )
416
+ PatStack :: from_vec ( iter. into_iter ( ) . collect ( ) )
415
417
}
416
418
}
417
419
0 commit comments