Skip to content

Commit 03cf715

Browse files
Rollup merge of #154879 - Zalathar:pattern-ty, r=Nadrieril
Don't store `pattern_ty` in `TestableCase` This field's only remaining use was in an assertion, but we can perform the same assertion earlier when constructing `TestableCase::Range`. --- For background, the `pattern_ty` field was introduced in #136435 to replace a reference to the full THIR pattern node. Since then, most uses of `pattern_ty` were removed by #150238.
2 parents 7300b25 + f9430bb commit 03cf715

3 files changed

Lines changed: 4 additions & 9 deletions

File tree

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ impl<'tcx> MatchPairTree<'tcx> {
152152
}
153153

154154
PatKind::Range(ref range) => {
155+
assert_eq!(pattern.ty, range.ty);
155156
if range.is_full_range(cx.tcx) == Some(true) {
156157
None
157158
} else {
@@ -380,7 +381,6 @@ impl<'tcx> MatchPairTree<'tcx> {
380381
place,
381382
testable_case,
382383
subpairs,
383-
pattern_ty: pattern.ty,
384384
pattern_span: pattern.span,
385385
})
386386
} else {

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ enum PatConstKind {
12771277
/// tested, and a test to perform on that place.
12781278
///
12791279
/// Each node also has a list of subpairs (possibly empty) that must also match,
1280-
/// and a reference to the THIR pattern it represents.
1280+
/// and some additional information from the THIR pattern it represents.
12811281
#[derive(Debug, Clone)]
12821282
pub(crate) struct MatchPairTree<'tcx> {
12831283
/// This place...
@@ -1301,9 +1301,7 @@ pub(crate) struct MatchPairTree<'tcx> {
13011301
/// that tests its field for the value `3`.
13021302
subpairs: Vec<Self>,
13031303

1304-
/// Type field of the pattern this node was created from.
1305-
pattern_ty: Ty<'tcx>,
1306-
/// Span field of the pattern this node was created from.
1304+
/// Span field of the THIR pattern this node was created from.
13071305
pattern_span: Span,
13081306
}
13091307

compiler/rustc_mir_build/src/builder/matches/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4444
TestKind::ScalarEq { value }
4545
}
4646

47-
TestableCase::Range(ref range) => {
48-
assert_eq!(range.ty, match_pair.pattern_ty);
49-
TestKind::Range(Arc::clone(range))
50-
}
47+
TestableCase::Range(ref range) => TestKind::Range(Arc::clone(range)),
5148

5249
TestableCase::Slice { len, op } => TestKind::SliceLen { len, op },
5350

0 commit comments

Comments
 (0)