diff options
| author | bors <bors@rust-lang.org> | 2022-04-16 19:15:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-16 19:15:02 +0000 |
| commit | 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 (patch) | |
| tree | 3775849e21447f36051ce13cbfa6620fba74fa8e /compiler/rustc_ast_pretty/src/pprust | |
| parent | 2fa9789f596dd7639e1a242d466637b53179f4d1 (diff) | |
| parent | 10e0db5666c15ed58abb47aca1ee453e371c406f (diff) | |
| download | rust-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')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index c2247150d09..3c9bb81bedb 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -959,7 +959,7 @@ impl<'a> State<'a> { self.word_space("="); match term { Term::Ty(ty) => self.print_type(ty), - Term::Const(c) => self.print_expr_anon_const(c), + Term::Const(c) => self.print_expr_anon_const(c, &[]), } } ast::AssocConstraintKind::Bound { bounds } => self.print_type_bounds(":", &*bounds), 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); |
