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.
This commit is contained in:
Nadrieril 2024-01-21 21:25:55 +01:00
parent 4316d0c625
commit 48b83e8a63
2 changed files with 3 additions and 6 deletions

View File

@ -22,8 +22,6 @@ use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty};
use rustc_span::symbol::Symbol;
use rustc_span::{BytePos, Pos, Span};
use rustc_target::abi::VariantIdx;
use smallvec::{smallvec, SmallVec};
// helper functions, broken out by category:
mod simplify;
mod test;
@ -949,7 +947,7 @@ struct Candidate<'pat, 'tcx> {
has_guard: bool,
/// All of these must be satisfied...
match_pairs: SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
match_pairs: Vec<MatchPair<'pat, 'tcx>>,
/// ...these bindings established...
bindings: Vec<Binding<'tcx>>,
@ -979,7 +977,7 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
Candidate {
span: pattern.span,
has_guard,
match_pairs: smallvec![MatchPair::new(place, pattern, cx)],
match_pairs: vec![MatchPair::new(place, pattern, cx)],
bindings: Vec::new(),
ascriptions: Vec::new(),
subcandidates: Vec::new(),

View File

@ -6,7 +6,6 @@ use rustc_middle::mir::*;
use rustc_middle::thir::*;
use rustc_middle::ty;
use rustc_middle::ty::TypeVisitableExt;
use smallvec::SmallVec;
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub(crate) fn field_match_pairs<'pat>(
@ -26,7 +25,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub(crate) fn prefix_slice_suffix<'pat>(
&mut self,
match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
place: &PlaceBuilder<'tcx>,
prefix: &'pat [Box<Pat<'tcx>>],
opt_slice: &'pat Option<Box<Pat<'tcx>>>,