Push the decision to skip fields further down

This commit is contained in:
Nadrieril
2024-02-06 02:44:48 +01:00
parent be01e28dce
commit ab06037269
4 changed files with 26 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ use std::fmt;
use smallvec::{smallvec, SmallVec};
use crate::constructor::{Constructor, Slice, SliceKind};
use crate::TypeCx;
use crate::{SkipField, TypeCx};
use self::Constructor::*;
@@ -300,7 +300,11 @@ impl<Cx: TypeCx> WitnessPat<Cx> {
/// For example, if `ctor` is a `Constructor::Variant` for `Option::Some`, we get the pattern
/// `Some(_)`.
pub(crate) fn wild_from_ctor(cx: &Cx, ctor: Constructor<Cx>, ty: Cx::Ty) -> Self {
let fields = cx.ctor_sub_tys(&ctor, &ty).map(|ty| Self::wildcard(ty)).collect();
let fields = cx
.ctor_sub_tys(&ctor, &ty)
.filter(|(_, SkipField(skip))| !skip)
.map(|(ty, _)| Self::wildcard(ty))
.collect();
Self::new(ctor, fields, ty)
}