about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-16 19:15:02 +0000
committerbors <bors@rust-lang.org>2022-04-16 19:15:02 +0000
commit878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 (patch)
tree3775849e21447f36051ce13cbfa6620fba74fa8e /compiler/rustc_ast_pretty/src/pprust/state/expr.rs
parent2fa9789f596dd7639e1a242d466637b53179f4d1 (diff)
parent10e0db5666c15ed58abb47aca1ee453e371c406f (diff)
downloadrust-878c7833f6c1ff10e2fd89074e5bd4ef5ff15936.tar.gz
rust-878c7833f6c1ff10e2fd89074e5bd4ef5ff15936.zip
Auto merge of #96123 - Dylan-DPC:rollup-qjog6n1, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #94985 (Parse inner attributes on inline const block)
 - #95006 (Reject `#[thread_local]` attribute on non-static items)
 - #95426 (Include Refs in Valtree Creation)
 - #95908 (Inline `shallow_resolve_ty` into `ShallowResolver`)
 - #96058 (separate flock implementations into separate modules)
 - #96088 (Update mdbook)
 - #96118 (rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust/state/expr.rs')
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/expr.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
index 6435f1b6141..9de4cbbee13 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
@@ -88,10 +88,21 @@ impl<'a> State<'a> {
         self.end();
     }
 
-    pub(super) fn print_expr_anon_const(&mut self, expr: &ast::AnonConst) {
+    pub(super) fn print_expr_anon_const(
+        &mut self,
+        expr: &ast::AnonConst,
+        attrs: &[ast::Attribute],
+    ) {
         self.ibox(INDENT_UNIT);
         self.word("const");
-        self.print_expr(&expr.value);
+        self.nbsp();
+        if let ast::ExprKind::Block(block, None) = &expr.value.kind {
+            self.cbox(0);
+            self.ibox(0);
+            self.print_block_with_attrs(block, attrs);
+        } else {
+            self.print_expr(&expr.value);
+        }
         self.end();
     }
 
@@ -275,7 +286,7 @@ impl<'a> State<'a> {
                 self.print_expr_vec(exprs);
             }
             ast::ExprKind::ConstBlock(ref anon_const) => {
-                self.print_expr_anon_const(anon_const);
+                self.print_expr_anon_const(anon_const, attrs);
             }
             ast::ExprKind::Repeat(ref element, ref count) => {
                 self.print_expr_repeat(element, count);