From 41778bd23d1be98816a791dea0378cc0e3e4ede1 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Mon, 6 May 2024 13:26:54 -0400 Subject: [PATCH] don't apply formatting to builtin type ascription syntax The syntax changed from `expr: ty` -> `builtin # type_acribe`. For now, rustfmt will just emit the contents of the span. --- src/expr.rs | 9 +-------- tests/target/issue_6159.rs | 3 +++ 2 files changed, 4 insertions(+), 8 deletions(-) create mode 100644 tests/target/issue_6159.rs diff --git a/src/expr.rs b/src/expr.rs index 4f7b88da6b2..7af3acc6708 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -253,14 +253,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) } @@ -402,6 +394,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, diff --git a/tests/target/issue_6159.rs b/tests/target/issue_6159.rs new file mode 100644 index 00000000000..49fd539d3ef --- /dev/null +++ b/tests/target/issue_6159.rs @@ -0,0 +1,3 @@ +fn main() { + builtin # type_ascribe(10, usize) +}