diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-03-25 23:43:54 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-04-30 17:40:27 -0700 |
| commit | e094ee5f102dfea8e99137d3818510cd178e8817 (patch) | |
| tree | 1355dfd0fa0c410199d17a4ea5f8889703a661db /compiler/rustc_ast_pretty/src | |
| parent | 2c858a7c3f189eb11ad89d9bf9f2e87cac9d2b76 (diff) | |
| download | rust-e094ee5f102dfea8e99137d3818510cd178e8817.tar.gz rust-e094ee5f102dfea8e99137d3818510cd178e8817.zip | |
Add `do yeet` expressions to allow experimentation in nightly
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
Diffstat (limited to 'compiler/rustc_ast_pretty/src')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 9de4cbbee13..9f44f1b6cc2 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -64,7 +64,10 @@ impl<'a> State<'a> { // parses as the erroneous construct `if (return {})`, not `if (return) {}`. pub(super) fn cond_needs_par(expr: &ast::Expr) -> bool { match expr.kind { - ast::ExprKind::Break(..) | ast::ExprKind::Closure(..) | ast::ExprKind::Ret(..) => true, + ast::ExprKind::Break(..) + | ast::ExprKind::Closure(..) + | ast::ExprKind::Ret(..) + | ast::ExprKind::Yeet(..) => true, _ => parser::contains_exterior_struct_lit(expr), } } @@ -502,6 +505,15 @@ impl<'a> State<'a> { self.print_expr_maybe_paren(expr, parser::PREC_JUMP); } } + ast::ExprKind::Yeet(ref result) => { + self.word("do"); + self.word(" "); + self.word("yeet"); + if let Some(ref expr) = *result { + self.word(" "); + self.print_expr_maybe_paren(expr, parser::PREC_JUMP); + } + } ast::ExprKind::InlineAsm(ref a) => { self.word("asm!"); self.print_inline_asm(a); |
