Introduce DotDotPos
.
This shrinks `hir::Pat` from 88 to 72 bytes.
This commit is contained in:
parent
4314615ff8
commit
e67f39f8bc
15 changed files with 85 additions and 47 deletions
|
@ -1128,8 +1128,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
|
||||
);
|
||||
// Destructure like a tuple struct.
|
||||
let tuple_struct_pat =
|
||||
hir::PatKind::TupleStruct(qpath, pats, rest.map(|r| r.0));
|
||||
let tuple_struct_pat = hir::PatKind::TupleStruct(
|
||||
qpath,
|
||||
pats,
|
||||
hir::DotDotPos::new(rest.map(|r| r.0)),
|
||||
);
|
||||
return self.pat_without_dbm(lhs.span, tuple_struct_pat);
|
||||
}
|
||||
}
|
||||
|
@ -1184,13 +1187,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
ExprKind::Tup(elements) => {
|
||||
let (pats, rest) =
|
||||
self.destructure_sequence(elements, "tuple", eq_sign_span, assignments);
|
||||
let tuple_pat = hir::PatKind::Tuple(pats, rest.map(|r| r.0));
|
||||
let tuple_pat = hir::PatKind::Tuple(pats, hir::DotDotPos::new(rest.map(|r| r.0)));
|
||||
return self.pat_without_dbm(lhs.span, tuple_pat);
|
||||
}
|
||||
ExprKind::Paren(e) => {
|
||||
// We special-case `(..)` for consistency with patterns.
|
||||
if let ExprKind::Range(None, None, RangeLimits::HalfOpen) = e.kind {
|
||||
let tuple_pat = hir::PatKind::Tuple(&[], Some(0));
|
||||
let tuple_pat = hir::PatKind::Tuple(&[], hir::DotDotPos::new(Some(0)));
|
||||
return self.pat_without_dbm(lhs.span, tuple_pat);
|
||||
} else {
|
||||
return self.destructure_assign_mut(e, eq_sign_span, assignments);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue