diff options
| author | bors <bors@rust-lang.org> | 2024-04-20 22:35:56 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-20 22:35:56 +0000 | 
| commit | 453ceafce32ef8108c604bca5e165ab41d3d6d8c (patch) | |
| tree | 291ff8649c049bbc4d4c1d73d99158e869f672e1 /compiler/rustc_ast_pretty/src/pprust/state.rs | |
| parent | dbce3b43b6cb34dd3ba12c3ec6f708fe68e9c3df (diff) | |
| parent | c72cfdd46fff49c382d3834b4f0e48d75aedb970 (diff) | |
| download | rust-453ceafce32ef8108c604bca5e165ab41d3d6d8c.tar.gz rust-453ceafce32ef8108c604bca5e165ab41d3d6d8c.zip | |
Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu
Rollup of 10 pull requests Successful merges: - #123379 (Print note with closure signature on type mismatch) - #123967 (static_mut_refs: use raw pointers to remove the remaining FIXME) - #123976 (Use fake libc in core test) - #123986 (lint-docs: Add redirects for renamed lints.) - #124053 (coverage: Branch coverage tests for lazy boolean operators) - #124071 (Add llvm-bitcode-linker to build manifest) - #124103 (Improve std::fs::Metadata Debug representation) - #124132 (llvm RustWrapper: explain OpBundlesIndirect argument type) - #124191 (Give a name to each distinct manipulation of pretty-printer FixupContext) - #124196 (mir-opt tests: rename unit-test -> test-mir-pass) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust/state.rs')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 25 | 
1 files changed, 6 insertions, 19 deletions
| diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 293e65ce872..2c176828c84 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -3,11 +3,12 @@ //! Note that HIR pretty printing is layered on top of this crate. mod expr; +mod fixup; mod item; use crate::pp::Breaks::{Consistent, Inconsistent}; use crate::pp::{self, Breaks}; -use crate::pprust::state::expr::FixupContext; +use crate::pprust::state::fixup::FixupContext; use ast::TraitBoundModifiers; use rustc_ast::attr::AttrIdGenerator; use rustc_ast::ptr::P; @@ -15,7 +16,6 @@ use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, To use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree}; use rustc_ast::util::classify; use rustc_ast::util::comments::{Comment, CommentStyle}; -use rustc_ast::util::parser; use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind}; use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term}; use rustc_ast::{GenericArg, GenericBound, SelfKind}; @@ -1252,22 +1252,14 @@ impl<'a> State<'a> { ast::StmtKind::Item(item) => self.print_item(item), ast::StmtKind::Expr(expr) => { self.space_if_not_bol(); - self.print_expr_outer_attr_style( - expr, - false, - FixupContext { stmt: true, ..FixupContext::default() }, - ); + self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt()); if classify::expr_requires_semi_to_be_stmt(expr) { self.word(";"); } } ast::StmtKind::Semi(expr) => { self.space_if_not_bol(); - self.print_expr_outer_attr_style( - expr, - false, - FixupContext { stmt: true, ..FixupContext::default() }, - ); + self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt()); self.word(";"); } ast::StmtKind::Empty => { @@ -1319,11 +1311,7 @@ impl<'a> State<'a> { ast::StmtKind::Expr(expr) if i == blk.stmts.len() - 1 => { self.maybe_print_comment(st.span.lo()); self.space_if_not_bol(); - self.print_expr_outer_attr_style( - expr, - false, - FixupContext { stmt: true, ..FixupContext::default() }, - ); + self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt()); self.maybe_print_trailing_comment(expr.span, Some(blk.span.hi())); } _ => self.print_stmt(st), @@ -1367,8 +1355,7 @@ impl<'a> State<'a> { self.word_space("="); self.print_expr_cond_paren( expr, - fixup.parenthesize_exterior_struct_lit && parser::contains_exterior_struct_lit(expr) - || parser::needs_par_as_let_scrutinee(expr.precedence().order()), + fixup.needs_par_as_let_scrutinee(expr), FixupContext::default(), ); } | 
