From 621494382da59e3a899a968e7d445170dd37ba1d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 20 Oct 2023 21:26:57 +0000 Subject: [PATCH] Add gen blocks to ast and do some broken ast lowering --- compiler/rustc_ast/src/ast.rs | 32 ++++++++-- compiler/rustc_ast/src/mut_visit.rs | 2 +- compiler/rustc_ast/src/util/classify.rs | 2 +- compiler/rustc_ast/src/util/parser.rs | 4 +- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 61 ++++++++++++++++++- .../rustc_ast_pretty/src/pprust/state/expr.rs | 4 +- .../src/assert/context.rs | 2 +- compiler/rustc_parse/src/parser/expr.rs | 32 +++++----- compiler/rustc_passes/src/hir_stats.rs | 4 +- compiler/rustc_resolve/src/def_collector.rs | 2 +- compiler/rustc_resolve/src/late.rs | 2 +- .../src/suspicious_operation_groupings.rs | 2 +- .../clippy/clippy_utils/src/ast_utils.rs | 2 +- src/tools/clippy/clippy_utils/src/sugg.rs | 2 +- src/tools/rustfmt/src/closures.rs | 2 +- src/tools/rustfmt/src/expr.rs | 8 +-- src/tools/rustfmt/src/utils.rs | 2 +- tests/ui/coroutine/gen_block.e2024.stderr | 9 ++- tests/ui/coroutine/gen_block.none.stderr | 8 +-- tests/ui/coroutine/gen_block.rs | 3 +- 21 files changed, 131 insertions(+), 56 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 543c528db448..aceee07a7341 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1232,7 +1232,7 @@ impl Expr { ExprKind::Closure(..) => ExprPrecedence::Closure, ExprKind::Block(..) => ExprPrecedence::Block, ExprKind::TryBlock(..) => ExprPrecedence::TryBlock, - ExprKind::Async(..) => ExprPrecedence::Async, + ExprKind::Gen(..) => ExprPrecedence::Gen, ExprKind::Await(..) => ExprPrecedence::Await, ExprKind::Assign(..) => ExprPrecedence::Assign, ExprKind::AssignOp(..) => ExprPrecedence::AssignOp, @@ -1401,11 +1401,9 @@ pub enum ExprKind { Closure(Box), /// A block (`'label: { ... }`). Block(P, Option