Use .map.collect to aggregate in .to_ty of tuples

This commit is contained in:
lapla 2026-02-07 11:42:53 +09:00
parent efc9e1b50c
commit b5cd820ef4
No known key found for this signature in database
GPG key ID: B39C71D9F127FF9F

View file

@ -656,11 +656,7 @@ impl Pat {
// A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
// assuming `T0` to `Tn` are all syntactically valid as types.
PatKind::Tuple(pats) => {
let mut tys = ThinVec::with_capacity(pats.len());
// FIXME(#48994) - could just be collected into an Option<Vec>
for pat in pats {
tys.push(pat.to_ty()?);
}
let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<ThinVec<_>>>()?;
TyKind::Tup(tys)
}
_ => return None,