1
Fork 0

Let ctor_sub_tys return any Iterator they want

Since we always clone and allocate the types somewhere else ourselves,
no need to ask for `Cx` to do the allocation.
This commit is contained in:
Nadrieril 2024-01-24 16:55:26 +01:00
parent cd6d8f2a04
commit e088016f9d
4 changed files with 24 additions and 19 deletions

View file

@ -241,8 +241,7 @@ 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(pcx: &PlaceCtxt<'_, Cx>, ctor: Constructor<Cx>) -> Self {
let field_tys = pcx.ctor_sub_tys(&ctor);
let fields = field_tys.iter().cloned().map(|ty| Self::wildcard(ty)).collect();
let fields = pcx.ctor_sub_tys(&ctor).map(|ty| Self::wildcard(ty)).collect();
Self::new(ctor, fields, pcx.ty.clone())
}