Skip to content

Commit c956c65

Browse files
committed
Name the field of PatStack
1 parent 3aa5fb3 commit c956c65

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,43 +337,45 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
337337
/// A row of a matrix. Rows of len 1 are very common, which is why `SmallVec[_; 2]`
338338
/// works well.
339339
#[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+
}
341343

342344
impl<'p, 'tcx> PatStack<'p, 'tcx> {
343345
pub fn from_pattern(pat: &'p Pat<'tcx>) -> Self {
344-
PatStack(smallvec![pat])
346+
PatStack::from_vec(smallvec![pat])
345347
}
346348

347349
fn empty() -> Self {
348-
PatStack(smallvec![])
350+
PatStack::from_vec(smallvec![])
349351
}
350352

351353
fn from_vec(vec: SmallVec<[&'p Pat<'tcx>; 2]>) -> Self {
352-
PatStack(vec)
354+
PatStack { patterns: vec }
353355
}
354356

355357
fn from_slice(s: &[&'p Pat<'tcx>]) -> Self {
356-
PatStack(SmallVec::from_slice(s))
358+
PatStack::from_vec(SmallVec::from_slice(s))
357359
}
358360

359361
fn is_empty(&self) -> bool {
360-
self.0.is_empty()
362+
self.patterns.is_empty()
361363
}
362364

363365
fn len(&self) -> usize {
364-
self.0.len()
366+
self.patterns.len()
365367
}
366368

367369
fn head<'a>(&'a self) -> &'p Pat<'tcx> {
368-
self.0[0]
370+
self.patterns[0]
369371
}
370372

371373
fn head_ctors(&self, cx: &MatchCheckCtxt<'_, 'tcx>) -> SmallVec<[Constructor<'tcx>; 1]> {
372374
pat_constructors(cx.tcx, cx.param_env, self.head())
373375
}
374376

375377
fn iter(&self) -> impl Iterator<Item = &Pat<'tcx>> {
376-
self.0.iter().map(|p| *p)
378+
self.patterns.iter().map(|p| *p)
377379
}
378380

379381
/// This computes `S(constructor, self)`. See top of the file for explanations.
@@ -391,7 +393,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
391393
let result = new_heads
392394
.into_iter()
393395
.map(|mut new_head| {
394-
new_head.0.extend_from_slice(&self.0[1..]);
396+
new_head.patterns.extend_from_slice(&self.patterns[1..]);
395397
new_head
396398
})
397399
.collect();
@@ -402,7 +404,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
402404

403405
impl<'p, 'tcx> Default for PatStack<'p, 'tcx> {
404406
fn default() -> Self {
405-
PatStack(smallvec![])
407+
PatStack::empty()
406408
}
407409
}
408410

@@ -411,7 +413,7 @@ impl<'p, 'tcx> FromIterator<&'p Pat<'tcx>> for PatStack<'p, 'tcx> {
411413
where
412414
T: IntoIterator<Item = &'p Pat<'tcx>>,
413415
{
414-
PatStack(iter.into_iter().collect())
416+
PatStack::from_vec(iter.into_iter().collect())
415417
}
416418
}
417419

0 commit comments

Comments
 (0)