Skip to content

Commit 51be999

Browse files
authored
Unrolled build for rust-lang#124637
Rollup merge of rust-lang#124637 - fmease:ast-pretty-ty-asc-builtin-syn, r=compiler-errors AST pretty: Use `builtin_syntax` for type ascription Follow-up to rust-lang#122806. CC #124619.
2 parents 79734f1 + 3a3df3e commit 51be999

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

compiler/rustc_ast/src/ast.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ pub struct StructExpr {
13901390
// Adding a new variant? Please update `test_expr` in `tests/ui/macros/stringify.rs`.
13911391
#[derive(Clone, Encodable, Decodable, Debug)]
13921392
pub enum ExprKind {
1393-
/// An array (`[a, b, c, d]`)
1393+
/// An array (e.g, `[a, b, c, d]`).
13941394
Array(ThinVec<P<Expr>>),
13951395
/// Allow anonymous constants from an inline `const` block
13961396
ConstBlock(AnonConst),
@@ -1401,7 +1401,7 @@ pub enum ExprKind {
14011401
/// This also represents calling the constructor of
14021402
/// tuple-like ADTs such as tuple structs and enum variants.
14031403
Call(P<Expr>, ThinVec<P<Expr>>),
1404-
/// A method call (e.g. `x.foo::<Bar, Baz>(a, b, c)`).
1404+
/// A method call (e.g., `x.foo::<Bar, Baz>(a, b, c)`).
14051405
MethodCall(Box<MethodCall>),
14061406
/// A tuple (e.g., `(a, b, c, d)`).
14071407
Tup(ThinVec<P<Expr>>),
@@ -1413,7 +1413,10 @@ pub enum ExprKind {
14131413
Lit(token::Lit),
14141414
/// A cast (e.g., `foo as f64`).
14151415
Cast(P<Expr>, P<Ty>),
1416-
/// A type ascription (e.g., `42: usize`).
1416+
/// A type ascription (e.g., `builtin # type_ascribe(42, usize)`).
1417+
///
1418+
/// Usually not written directly in user code but
1419+
/// indirectly via the macro `type_ascribe!(...)`.
14171420
Type(P<Expr>, P<Ty>),
14181421
/// A `let pat = expr` expression that is only semantically allowed in the condition
14191422
/// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`).
@@ -1488,7 +1491,10 @@ pub enum ExprKind {
14881491
/// Output of the `asm!()` macro.
14891492
InlineAsm(P<InlineAsm>),
14901493

1491-
/// Output of the `offset_of!()` macro.
1494+
/// An `offset_of` expression (e.g., `builtin # offset_of(Struct, field)`).
1495+
///
1496+
/// Usually not written directly in user code but
1497+
/// indirectly via the macro `core::mem::offset_of!(...)`.
14921498
OffsetOf(P<Ty>, P<[Ident]>),
14931499

14941500
/// A macro invocation; pre-expansion.

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl<'a> State<'a> {
422422
self.print_type(ty);
423423
}
424424
ast::ExprKind::Type(expr, ty) => {
425-
self.word("type_ascribe!(");
425+
self.word("builtin # type_ascribe");
426+
self.popen();
426427
self.ibox(0);
427428
self.print_expr(expr, FixupContext::default());
428429

@@ -431,7 +432,7 @@ impl<'a> State<'a> {
431432
self.print_type(ty);
432433

433434
self.end();
434-
self.word(")");
435+
self.pclose();
435436
}
436437
ast::ExprKind::Let(pat, scrutinee, _, _) => {
437438
self.print_let(pat, scrutinee, fixup);
@@ -657,15 +658,15 @@ impl<'a> State<'a> {
657658
);
658659
}
659660
ast::ExprKind::InlineAsm(a) => {
660-
// FIXME: This should have its own syntax, distinct from a macro invocation.
661+
// FIXME: Print `builtin # asm` once macro `asm` uses `builtin_syntax`.
661662
self.word("asm!");
662663
self.print_inline_asm(a);
663664
}
664665
ast::ExprKind::FormatArgs(fmt) => {
665-
// FIXME: This should have its own syntax, distinct from a macro invocation.
666+
// FIXME: Print `builtin # format_args` once macro `format_args` uses `builtin_syntax`.
666667
self.word("format_args!");
667668
self.popen();
668-
self.rbox(0, Inconsistent);
669+
self.ibox(0);
669670
self.word(reconstruct_format_args_template_string(&fmt.template));
670671
for arg in fmt.arguments.all_args() {
671672
self.word_space(",");
@@ -677,7 +678,7 @@ impl<'a> State<'a> {
677678
ast::ExprKind::OffsetOf(container, fields) => {
678679
self.word("builtin # offset_of");
679680
self.popen();
680-
self.rbox(0, Inconsistent);
681+
self.ibox(0);
681682
self.print_type(container);
682683
self.word(",");
683684
self.space();
@@ -690,8 +691,8 @@ impl<'a> State<'a> {
690691
self.print_ident(field);
691692
}
692693
}
693-
self.pclose();
694694
self.end();
695+
self.pclose();
695696
}
696697
ast::ExprKind::MacCall(m) => self.print_mac(m),
697698
ast::ExprKind::Paren(e) => {

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl<'a> State<'a> {
238238
self.bclose(item.span, empty);
239239
}
240240
ast::ItemKind::GlobalAsm(asm) => {
241+
// FIXME: Print `builtin # global_asm` once macro `global_asm` uses `builtin_syntax`.
241242
self.head(visibility_qualified(&item.vis, "global_asm!"));
242243
self.print_inline_asm(asm);
243244
self.word(";");

0 commit comments

Comments
 (0)