Skip to content

Commit 3715f1e

Browse files
committed
No need to expose Matrix internals
1 parent d447bdf commit 3715f1e

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_mir_build/src/thir/pattern

1 file changed

+6
-1
lines changed

compiler/rustc_mir_build/src/thir/pattern/_match.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
476476
Matrix { patterns: vec![] }
477477
}
478478

479+
/// Number of columns of this matrix. `None` is the matrix is empty.
480+
fn column_count(&self) -> Option<usize> {
481+
self.patterns.get(0).map(|r| r.len())
482+
}
483+
479484
/// Pushes a new row to the matrix. If the row starts with an or-pattern, this expands it.
480485
fn push(&mut self, row: PatStack<'p, 'tcx>) {
481486
if let Some(rows) = row.expand_or_pat() {
@@ -1897,7 +1902,7 @@ impl<'tcx> IntRange<'tcx> {
18971902
// Collect the span and range of all the intersecting ranges to lint on likely
18981903
// incorrect range patterns. (#63987)
18991904
let mut overlaps = vec![];
1900-
let row_len = pcx.matrix.patterns.get(0).map(|r| r.len()).unwrap_or(0);
1905+
let row_len = pcx.matrix.column_count().unwrap_or(0);
19011906
// `borders` is the set of borders between equivalence classes: each equivalence
19021907
// class lies between 2 borders.
19031908
let row_borders = pcx

0 commit comments

Comments
 (0)