We only need the arity of the subtype list now

This commit is contained in:
Nadrieril
2024-01-03 01:25:32 +01:00
parent 4ae2840e84
commit 1a3edc169b
3 changed files with 13 additions and 18 deletions

View File

@@ -72,11 +72,10 @@ impl<'p, Cx: TypeCx> DeconstructedPat<'p, Cx> {
/// `other_ctor` can be different from `self.ctor`, but must be covered by it.
pub(crate) fn specialize(
&self,
_pcx: &PlaceCtxt<'_, 'p, Cx>,
other_ctor: &Constructor<Cx>,
ctor_sub_tys: &[Cx::Ty],
ctor_arity: usize,
) -> SmallVec<[PatOrWild<'p, Cx>; 2]> {
let wildcard_sub_tys = || ctor_sub_tys.iter().map(|_| Wild).collect();
let wildcard_sub_tys = || (0..ctor_arity).map(|_| Wild).collect();
match (&self.ctor, other_ctor) {
// Return a wildcard for each field of `other_ctor`.
(Wildcard, _) => wildcard_sub_tys(),
@@ -195,13 +194,12 @@ impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
/// `other_ctor` can be different from `self.ctor`, but must be covered by it.
pub(crate) fn specialize(
&self,
pcx: &PlaceCtxt<'_, 'p, Cx>,
other_ctor: &Constructor<Cx>,
ctor_sub_tys: &[Cx::Ty],
ctor_arity: usize,
) -> SmallVec<[PatOrWild<'p, Cx>; 2]> {
match self {
Wild => ctor_sub_tys.iter().map(|_| Wild).collect(),
Pat(pat) => pat.specialize(pcx, other_ctor, ctor_sub_tys),
Wild => (0..ctor_arity).map(|_| Wild).collect(),
Pat(pat) => pat.specialize(other_ctor, ctor_arity),
}
}