Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #93498

Merged
merged 24 commits into from
Jan 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
521b1ee
Improve terminology around "after typeck"
pierwill Oct 25, 2021
d671948
Allow eliding GATs in expr position
compiler-errors Jan 15, 2022
32ab0b8
respect doc(hidden) when suggesting available fields
ibraheemdev Jan 22, 2022
b734abc
Handle unstability as well, including "field typo suggestions"
danielhenrymantilla Jan 24, 2022
ecd06e1
Don't suggest inaccessible fields
terrarier2111 Jan 18, 2022
cd4245d
Make char::DecodeUtf16::size_hist more precise
WaffleLapkin Jan 26, 2022
9c8cd1f
Add a test for `char::DecodeUtf16::size_hint`
WaffleLapkin Jan 26, 2022
2fb617c
Clarify documentation on char::MAX
GKFX Jan 27, 2022
2c97d10
Fix wrong assumption in `DecodeUtf16::size_hint`
WaffleLapkin Jan 28, 2022
f8a013f
Fix some CSS warnings and errors from VS Code
camelid Jan 7, 2022
17cd2cd
Fix an edge case in `chat::DecodeUtf16::size_hint`
WaffleLapkin Jan 30, 2022
9aaf52b
(#93392) Update char::MAX docs and core::char::MAX
GKFX Jan 30, 2022
cb93e9c
Compute indent never relative to current column
dtolnay Jan 21, 2022
8ac05b9
Fix some double indents on exprs containing blocks
dtolnay Jan 21, 2022
402f322
Bless all pretty printer tests and ui tests
dtolnay Jan 21, 2022
125c729
Restore a visual alignment mode for block comments
dtolnay Jan 21, 2022
6749f32
Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726
matthiaskrgr Jan 31, 2022
55d5513
Rollup merge of #92918 - compiler-errors:gat-expr-lifetime-elision, r…
matthiaskrgr Jan 31, 2022
71efe90
Rollup merge of #93039 - terrarier2111:fix-field-help, r=nagisa
matthiaskrgr Jan 31, 2022
1cb22e4
Rollup merge of #93155 - dtolnay:blockindent, r=nagisa
matthiaskrgr Jan 31, 2022
7de90d5
Rollup merge of #93214 - ibraheemdev:issue-93210, r=davidtwco
matthiaskrgr Jan 31, 2022
76857fb
Rollup merge of #93347 - WaffleLapkin:better_char_decode_utf16_size_h…
matthiaskrgr Jan 31, 2022
c03bf54
Rollup merge of #93392 - GKFX:char-docs, r=scottmcm
matthiaskrgr Jan 31, 2022
2070b22
Rollup merge of #93444 - camelid:rustdoc-css-cleanup, r=GuillaumeGome…
matthiaskrgr Jan 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some double indents on exprs containing blocks
The `print_expr` method already places an `ibox(INDENT_UNIT)` around
every expr that gets printed. Some exprs were then using `self.head`
inside of that, which does its own `cbox(INDENT_UNIT)`, resulting in two
levels of indentation:

    while true {
            stuff;
        }

This commit fixes those cases to produce the expected single level of
indentation within every expression containing a block.

    while true {
        stuff;
    }
dtolnay committed Jan 31, 2022
commit 8ac05b97660ec3bd5e8f0d3b7edb246b6cea9c32
24 changes: 16 additions & 8 deletions compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
@@ -320,7 +320,9 @@ impl<'a> State<'a> {
self.print_ident(label.ident);
self.word_space(":");
}
self.head("while");
self.cbox(0);
self.ibox(0);
self.word_nbsp("while");
self.print_expr_as_cond(test);
self.space();
self.print_block_with_attrs(blk, attrs);
@@ -330,7 +332,9 @@ impl<'a> State<'a> {
self.print_ident(label.ident);
self.word_space(":");
}
self.head("for");
self.cbox(0);
self.ibox(0);
self.word_nbsp("for");
self.print_pat(pat);
self.space();
self.word_space("in");
@@ -343,12 +347,14 @@ impl<'a> State<'a> {
self.print_ident(label.ident);
self.word_space(":");
}
self.head("loop");
self.cbox(0);
self.ibox(0);
self.word_nbsp("loop");
self.print_block_with_attrs(blk, attrs);
}
ast::ExprKind::Match(ref expr, ref arms) => {
self.cbox(INDENT_UNIT);
self.ibox(INDENT_UNIT);
self.cbox(0);
self.ibox(0);
self.word_nbsp("match");
self.print_expr_as_cond(expr);
self.space();
@@ -388,7 +394,7 @@ impl<'a> State<'a> {
self.word_space(":");
}
// containing cbox, will be closed by print-block at }
self.cbox(INDENT_UNIT);
self.cbox(0);
// head-box, will be closed by print-block after {
self.ibox(0);
self.print_block_with_attrs(blk, attrs);
@@ -397,7 +403,7 @@ impl<'a> State<'a> {
self.word_nbsp("async");
self.print_capture_clause(capture_clause);
// cbox/ibox in analogy to the `ExprKind::Block` arm above
self.cbox(INDENT_UNIT);
self.cbox(0);
self.ibox(0);
self.print_block_with_attrs(blk, attrs);
}
@@ -500,7 +506,9 @@ impl<'a> State<'a> {
self.word("?")
}
ast::ExprKind::TryBlock(ref blk) => {
self.head("try");
self.cbox(0);
self.ibox(0);
self.word_nbsp("try");
self.print_block_with_attrs(blk, attrs)
}
ast::ExprKind::Err => {
4 changes: 2 additions & 2 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::pp::Breaks::Inconsistent;
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
use crate::pprust::state::{AnnNode, PrintState, State};

use rustc_ast as ast;
use rustc_ast::GenericBound;
@@ -377,7 +377,7 @@ impl<'a> State<'a> {
self.space_if_not_bol();
self.maybe_print_comment(v.span.lo());
self.print_outer_attributes(&v.attrs);
self.ibox(INDENT_UNIT);
self.ibox(0);
self.print_variant(v);
self.word(",");
self.end();