Skip to content

Commit 453ceaf

Browse files
committed
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
2 parents dbce3b4 + c72cfdd commit 453ceaf

File tree

184 files changed

+912
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+912
-421
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
//! Note that HIR pretty printing is layered on top of this crate.
44
55
mod expr;
6+
mod fixup;
67
mod item;
78

89
use crate::pp::Breaks::{Consistent, Inconsistent};
910
use crate::pp::{self, Breaks};
10-
use crate::pprust::state::expr::FixupContext;
11+
use crate::pprust::state::fixup::FixupContext;
1112
use ast::TraitBoundModifiers;
1213
use rustc_ast::attr::AttrIdGenerator;
1314
use rustc_ast::ptr::P;
1415
use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, Token, TokenKind};
1516
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1617
use rustc_ast::util::classify;
1718
use rustc_ast::util::comments::{Comment, CommentStyle};
18-
use rustc_ast::util::parser;
1919
use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind};
2020
use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term};
2121
use rustc_ast::{GenericArg, GenericBound, SelfKind};
@@ -1252,22 +1252,14 @@ impl<'a> State<'a> {
12521252
ast::StmtKind::Item(item) => self.print_item(item),
12531253
ast::StmtKind::Expr(expr) => {
12541254
self.space_if_not_bol();
1255-
self.print_expr_outer_attr_style(
1256-
expr,
1257-
false,
1258-
FixupContext { stmt: true, ..FixupContext::default() },
1259-
);
1255+
self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt());
12601256
if classify::expr_requires_semi_to_be_stmt(expr) {
12611257
self.word(";");
12621258
}
12631259
}
12641260
ast::StmtKind::Semi(expr) => {
12651261
self.space_if_not_bol();
1266-
self.print_expr_outer_attr_style(
1267-
expr,
1268-
false,
1269-
FixupContext { stmt: true, ..FixupContext::default() },
1270-
);
1262+
self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt());
12711263
self.word(";");
12721264
}
12731265
ast::StmtKind::Empty => {
@@ -1319,11 +1311,7 @@ impl<'a> State<'a> {
13191311
ast::StmtKind::Expr(expr) if i == blk.stmts.len() - 1 => {
13201312
self.maybe_print_comment(st.span.lo());
13211313
self.space_if_not_bol();
1322-
self.print_expr_outer_attr_style(
1323-
expr,
1324-
false,
1325-
FixupContext { stmt: true, ..FixupContext::default() },
1326-
);
1314+
self.print_expr_outer_attr_style(expr, false, FixupContext::new_stmt());
13271315
self.maybe_print_trailing_comment(expr.span, Some(blk.span.hi()));
13281316
}
13291317
_ => self.print_stmt(st),
@@ -1367,8 +1355,7 @@ impl<'a> State<'a> {
13671355
self.word_space("=");
13681356
self.print_expr_cond_paren(
13691357
expr,
1370-
fixup.parenthesize_exterior_struct_lit && parser::contains_exterior_struct_lit(expr)
1371-
|| parser::needs_par_as_let_scrutinee(expr.precedence().order()),
1358+
fixup.needs_par_as_let_scrutinee(expr),
13721359
FixupContext::default(),
13731360
);
13741361
}

0 commit comments

Comments
 (0)