diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-15 19:37:14 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-15 19:37:14 +0900 |
| commit | 87e373e82f1791e42d09c1adc9170879304e62cb (patch) | |
| tree | d563ff456f1b285e0be45b2384e28eb270473317 /compiler/rustc_middle/src/hir | |
| parent | 40912e12f1eb35434fc5489adb6ddcb9b976a7e4 (diff) | |
| parent | 3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac (diff) | |
| download | rust-87e373e82f1791e42d09c1adc9170879304e62cb.tar.gz rust-87e373e82f1791e42d09c1adc9170879304e62cb.zip | |
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``
Diffstat (limited to 'compiler/rustc_middle/src/hir')
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 0f1597e66e7..0826cd79375 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -22,7 +22,7 @@ fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> { Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. }) | Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(sig, _), .. }) | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(sig, _), .. }) => Some(&sig.decl), - Node::Expr(Expr { kind: ExprKind::Closure(_, fn_decl, ..), .. }) + Node::Expr(Expr { kind: ExprKind::Closure { fn_decl, .. }, .. }) | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, ..), .. }) => { Some(fn_decl) } @@ -54,7 +54,7 @@ pub fn associated_body<'hir>(node: Node<'hir>) -> Option<BodyId> { kind: ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body), .. }) - | Node::Expr(Expr { kind: ExprKind::Closure(.., body, _, _), .. }) => Some(*body), + | Node::Expr(Expr { kind: ExprKind::Closure { body, .. }, .. }) => Some(*body), Node::AnonConst(constant) => Some(constant.body), @@ -285,8 +285,8 @@ impl<'hir> Map<'hir> { } Node::Field(_) => DefKind::Field, Node::Expr(expr) => match expr.kind { - ExprKind::Closure(.., None) => DefKind::Closure, - ExprKind::Closure(.., Some(_)) => DefKind::Generator, + ExprKind::Closure { movability: None, .. } => DefKind::Closure, + ExprKind::Closure { movability: Some(_), .. } => DefKind::Generator, _ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)), }, Node::GenericParam(param) => match param.kind { @@ -758,7 +758,7 @@ impl<'hir> Map<'hir> { Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) - | Node::Expr(Expr { kind: ExprKind::Closure(..), .. }) + | Node::Expr(Expr { kind: ExprKind::Closure { .. }, .. }) | Node::ImplItem(_) => return Some(hir_id), // Ignore `return`s on the first iteration Node::Expr(Expr { kind: ExprKind::Loop(..) | ExprKind::Ret(..), .. }) |
