1
Fork 0

Add an indirection for closures in hir::ExprKind

This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
This commit is contained in:
Maybe Waffle 2022-07-11 23:39:53 +04:00
parent 3ebb852956
commit df4fee9841
26 changed files with 101 additions and 79 deletions

View file

@ -68,9 +68,10 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
// Figure out what primary body this item has.
let (body_id, return_ty_span, span_with_body) = match tcx.hir().get(id) {
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure { fn_decl, body, .. }, .. }) => {
(*body, fn_decl.output.span(), None)
}
Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(hir::Closure { fn_decl, body, .. }),
..
}) => (*body, fn_decl.output.span(), None),
Node::Item(hir::Item {
kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
span,