don't apply formatting to builtin type ascription syntax

The syntax changed from `expr: ty` -> `builtin # type_ascribe(expr, ty)`
For now, rustfmt will just emit the contents of the span.
This commit is contained in:
Yacin Tmimi 2024-05-06 13:26:54 -04:00
parent 8c4c336e37
commit 8e80f8aa3a
3 changed files with 11 additions and 8 deletions

View File

@ -8,6 +8,13 @@
[bytecount#92]: https://github.com/llogiq/bytecount/pull/92 [bytecount#92]: https://github.com/llogiq/bytecount/pull/92
[bytecount#93]: https://github.com/llogiq/bytecount/pull/93 [bytecount#93]: https://github.com/llogiq/bytecount/pull/93
- Output correct syntax for type ascription builtin [#6159](https://github.com/rust-lang/rustfmt/issues/6159)
```rust
fn main() {
builtin # type_ascribe(10, usize)
}
```
## [1.7.0] 2023-10-22 ## [1.7.0] 2023-10-22
### Fixed ### Fixed

View File

@ -263,14 +263,6 @@ pub(crate) fn format_expr(
shape, shape,
SeparatorPlace::Front, 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, _) => { ast::ExprKind::Index(ref expr, ref index, _) => {
rewrite_index(&**expr, &**index, context, shape) rewrite_index(&**expr, &**index, context, shape)
} }
@ -412,6 +404,7 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool {
} }
ast::ExprKind::Underscore => Some("_".to_owned()), ast::ExprKind::Underscore => Some("_".to_owned()),
ast::ExprKind::FormatArgs(..) ast::ExprKind::FormatArgs(..)
| ast::ExprKind::Type(..)
| ast::ExprKind::IncludedBytes(..) | ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::OffsetOf(..) => { | ast::ExprKind::OffsetOf(..) => {
// These don't normally occur in the AST because macros aren't expanded. However, // These don't normally occur in the AST because macros aren't expanded. However,

View File

@ -0,0 +1,3 @@
fn main() {
builtin # type_ascribe(10, usize)
}