Skip to content

Commit 4689da3

Browse files
committed
Switch to Vec of MatchPairs
Because I'm about to make MatchPair recursive, which I can't do with SmallVec, and I need to share code between the two.
1 parent e9bffde commit 4689da3

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty};
2222
use rustc_span::symbol::Symbol;
2323
use rustc_span::{BytePos, Pos, Span};
2424
use rustc_target::abi::VariantIdx;
25-
use smallvec::{smallvec, SmallVec};
26-
2725
// helper functions, broken out by category:
2826
mod simplify;
2927
mod test;
@@ -951,7 +949,7 @@ struct Candidate<'pat, 'tcx> {
951949
has_guard: bool,
952950

953951
/// All of these must be satisfied...
954-
match_pairs: SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
952+
match_pairs: Vec<MatchPair<'pat, 'tcx>>,
955953

956954
/// ...these bindings established...
957955
bindings: Vec<Binding<'tcx>>,
@@ -981,7 +979,7 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
981979
Candidate {
982980
span: pattern.span,
983981
has_guard,
984-
match_pairs: smallvec![MatchPair::new(place, pattern, cx)],
982+
match_pairs: vec![MatchPair::new(place, pattern, cx)],
985983
bindings: Vec::new(),
986984
ascriptions: Vec::new(),
987985
subcandidates: Vec::new(),

compiler/rustc_mir_build/src/build/matches/simplify.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use crate::build::expr::as_place::PlaceBuilder;
1616
use crate::build::matches::{Ascription, Binding, Candidate, MatchPair};
1717
use crate::build::Builder;
1818
use rustc_middle::thir::{self, *};
19-
use smallvec::SmallVec;
20-
2119
use std::mem;
2220

2321
impl<'a, 'tcx> Builder<'a, 'tcx> {
@@ -39,7 +37,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3937
&mut self,
4038
bindings: &mut Vec<Binding<'tcx>>,
4139
ascriptions: &mut Vec<Ascription<'tcx>>,
42-
match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
40+
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
4341
subcandidates: &mut Vec<Candidate<'pat, 'tcx>>,
4442
has_guard: bool,
4543
) -> bool {
@@ -61,7 +59,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6159
&mut self,
6260
candidate_bindings: &mut Vec<Binding<'tcx>>,
6361
candidate_ascriptions: &mut Vec<Ascription<'tcx>>,
64-
candidate_match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
62+
candidate_match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
6563
) {
6664
// repeatedly simplify match pairs until fixed point is reached
6765

@@ -177,7 +175,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
177175
match_pair: MatchPair<'pat, 'tcx>,
178176
bindings: &mut Vec<Binding<'tcx>>,
179177
ascriptions: &mut Vec<Ascription<'tcx>>,
180-
match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
178+
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
181179
) -> Result<(), MatchPair<'pat, 'tcx>> {
182180
match match_pair.pattern.kind {
183181
PatKind::AscribeUserType {

compiler/rustc_mir_build/src/build/matches/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_middle::mir::*;
66
use rustc_middle::thir::*;
77
use rustc_middle::ty;
88
use rustc_middle::ty::TypeVisitableExt;
9-
use smallvec::SmallVec;
109

1110
impl<'a, 'tcx> Builder<'a, 'tcx> {
1211
pub(crate) fn field_match_pairs<'pat>(
@@ -26,7 +25,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2625

2726
pub(crate) fn prefix_slice_suffix<'pat>(
2827
&mut self,
29-
match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
28+
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
3029
place: &PlaceBuilder<'tcx>,
3130
prefix: &'pat [Box<Pat<'tcx>>],
3231
opt_slice: &'pat Option<Box<Pat<'tcx>>>,

0 commit comments

Comments
 (0)