1
Fork 0

Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011

Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
This commit is contained in:
Yuki Okushi 2022-06-15 19:37:14 +09:00 committed by GitHub
commit 87e373e82f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 251 additions and 216 deletions

View file

@ -57,14 +57,14 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
hir::ExprKind::Loop(ref b, _, source, _) => {
self.with_context(Loop(source), |v| v.visit_block(&b));
}
hir::ExprKind::Closure(_, ref function_decl, b, span, movability) => {
hir::ExprKind::Closure { ref fn_decl, body, fn_decl_span, movability, .. } => {
let cx = if let Some(Movability::Static) = movability {
AsyncClosure(span)
AsyncClosure(fn_decl_span)
} else {
Closure(span)
Closure(fn_decl_span)
};
self.visit_fn_decl(&function_decl);
self.with_context(cx, |v| v.visit_nested_body(b));
self.visit_fn_decl(&fn_decl);
self.with_context(cx, |v| v.visit_nested_body(body));
}
hir::ExprKind::Block(ref b, Some(_label)) => {
self.with_context(LabeledBlock, |v| v.visit_block(&b));