diff options
| author | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2024-06-17 15:47:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-17 15:47:07 -0500 |
| commit | 3ffd7d46a998b0e8d0a0a15213df2f264c5bc3be (patch) | |
| tree | 2c2e4e3b34f64ec4c33d52be00d665339d73b443 /src/expr.rs | |
| parent | 55a70266e27a85ecc0876d786480e6ec464d038f (diff) | |
| parent | 306ddabe0a4e08d6692aaa35736939c4613dd095 (diff) | |
Merge pull request #6193 from ytmimi/subtree-push-nightly-2024-06-13
subtree-push nightly-2024-06-13
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/expr.rs b/src/expr.rs index 8e92ef03770..8266f95fd70 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -3,7 +3,7 @@ use std::cmp::min; use itertools::Itertools; use rustc_ast::token::{Delimiter, Lit, LitKind}; -use rustc_ast::{ast, ptr, token, ForLoopKind}; +use rustc_ast::{ast, ptr, token, ForLoopKind, MatchKind}; use rustc_span::{BytePos, Span}; use crate::chains::rewrite_chain; @@ -180,8 +180,8 @@ pub(crate) fn format_expr( } } } - ast::ExprKind::Match(ref cond, ref arms) => { - rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs) + ast::ExprKind::Match(ref cond, ref arms, kind) => { + rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs, kind) } ast::ExprKind::Path(ref qself, ref path) => { rewrite_path(context, PathContext::Expr, qself, path, shape) @@ -263,14 +263,6 @@ pub(crate) fn format_expr( shape, SeparatorPlace::Front, ), - ast::ExprKind::Type(ref expr, ref ty) => rewrite_pair( - &**expr, - &**ty, - PairParts::infix(": "), - context, - shape, - SeparatorPlace::Back, - ), ast::ExprKind::Index(ref expr, ref index, _) => { rewrite_index(&**expr, &**index, context, shape) } @@ -412,6 +404,7 @@ pub(crate) fn format_expr( } ast::ExprKind::Underscore => Some("_".to_owned()), ast::ExprKind::FormatArgs(..) + | ast::ExprKind::Type(..) | ast::ExprKind::IncludedBytes(..) | ast::ExprKind::OffsetOf(..) => { // These don't normally occur in the AST because macros aren't expanded. However, @@ -420,7 +413,7 @@ pub(crate) fn format_expr( // Also, rustfmt might get passed the output from `-Zunpretty=expanded`. None } - ast::ExprKind::Err => None, + ast::ExprKind::Err(_) | ast::ExprKind::Dummy => None, }; expr_rw @@ -641,7 +634,7 @@ pub(crate) fn rewrite_cond( shape: Shape, ) -> Option<String> { match expr.kind { - ast::ExprKind::Match(ref cond, _) => { + ast::ExprKind::Match(ref cond, _, MatchKind::Prefix) => { // `match `cond` {` let cond_shape = match context.config.indent_style() { IndentStyle::Visual => shape.shrink_left(6).and_then(|s| s.sub_width(2))?, @@ -1963,7 +1956,7 @@ fn rewrite_unary_op( } pub(crate) enum RhsAssignKind<'ast> { - Expr(&'ast ast::ExprKind, Span), + Expr(&'ast ast::ExprKind, #[allow(dead_code)] Span), Bounds, Ty, } |
