Skip to content

Commit b5cd820

Browse files
committed
Use .map.collect to aggregate in .to_ty of tuples
1 parent efc9e1b commit b5cd820

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,7 @@ impl Pat {
656656
// A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
657657
// assuming `T0` to `Tn` are all syntactically valid as types.
658658
PatKind::Tuple(pats) => {
659-
let mut tys = ThinVec::with_capacity(pats.len());
660-
// FIXME(#48994) - could just be collected into an Option<Vec>
661-
for pat in pats {
662-
tys.push(pat.to_ty()?);
663-
}
659+
let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<ThinVec<_>>>()?;
664660
TyKind::Tup(tys)
665661
}
666662
_ => return None,

0 commit comments

Comments
 (0)