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 7 pull requests #92397

Merged
merged 22 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b1529a6
Visit patterns' literal expressions before binding new idents
compiler-errors Dec 24, 2021
60a1abe
Rename `rustdoc::html::render::cache` to `search_index`
camelid Dec 28, 2021
e19593f
rustdoc: Remove some unnecessary `cache` parameters
camelid Dec 28, 2021
2b801dc
Move `ExternalLocation` to `clean::types`
camelid Dec 28, 2021
bd6692c
Make `search_index` functions private where possible
camelid Dec 28, 2021
afb77a9
Coalesce two arguments as `&Function`
camelid Dec 28, 2021
5c8e8e5
Give clearer names to several search index functions
camelid Dec 28, 2021
406d6d4
docs(error-codes): Add long error explanation for E0227
TmLev Dec 28, 2021
4391a11
Parse and suggest moving where clauses after equals for type aliases
jackh726 Dec 20, 2021
cbccc4a
Remove pretty printer space inside block with only outer attrs
dtolnay Dec 28, 2021
636d6a3
Only special case struct fields for intra-doc links, not enum variants
jyn514 Dec 18, 2021
ad29c17
Print space after formal generic params in fn type
dtolnay Dec 23, 2021
7d1ec64
Remove unused parameter
camelid Dec 28, 2021
09104ad
Explain why struct fields are handled by assoc. item code
camelid Dec 28, 2021
908a9d4
Add regression test for #59502
camelid Dec 28, 2021
e313143
Rollup merge of #92075 - jyn514:resolve-cleanup, r=camelid
matthiaskrgr Dec 29, 2021
bee1471
Rollup merge of #92118 - jackh726:type-alias-position-error, r=petroc…
matthiaskrgr Dec 29, 2021
f044c6c
Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillot
matthiaskrgr Dec 29, 2021
0e41194
Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomez
matthiaskrgr Dec 29, 2021
c82b2bc
Rollup merge of #92351 - TmLev:master, r=GuillaumeGomez
matthiaskrgr Dec 29, 2021
5583010
Rollup merge of #92371 - dtolnay:attrblock, r=oli-obk
matthiaskrgr Dec 29, 2021
949769c
Rollup merge of #92372 - dtolnay:fntype, r=jackh726
matthiaskrgr Dec 29, 2021
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
23 changes: 12 additions & 11 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,23 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
self.print_string(sym.as_str(), style);
}

fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) {
fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) -> bool {
self.print_either_attributes(attrs, ast::AttrStyle::Inner, false, true)
}

fn print_inner_attributes_no_trailing_hardbreak(&mut self, attrs: &[ast::Attribute]) {
fn print_inner_attributes_no_trailing_hardbreak(&mut self, attrs: &[ast::Attribute]) -> bool {
self.print_either_attributes(attrs, ast::AttrStyle::Inner, false, false)
}

fn print_outer_attributes(&mut self, attrs: &[ast::Attribute]) {
fn print_outer_attributes(&mut self, attrs: &[ast::Attribute]) -> bool {
self.print_either_attributes(attrs, ast::AttrStyle::Outer, false, true)
}

fn print_inner_attributes_inline(&mut self, attrs: &[ast::Attribute]) {
fn print_inner_attributes_inline(&mut self, attrs: &[ast::Attribute]) -> bool {
self.print_either_attributes(attrs, ast::AttrStyle::Inner, true, true)
}

fn print_outer_attributes_inline(&mut self, attrs: &[ast::Attribute]) {
fn print_outer_attributes_inline(&mut self, attrs: &[ast::Attribute]) -> bool {
self.print_either_attributes(attrs, ast::AttrStyle::Outer, true, true)
}

Expand All @@ -413,20 +413,21 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
kind: ast::AttrStyle,
is_inline: bool,
trailing_hardbreak: bool,
) {
let mut count = 0;
) -> bool {
let mut printed = false;
for attr in attrs {
if attr.style == kind {
self.print_attribute_inline(attr, is_inline);
if is_inline {
self.nbsp();
}
count += 1;
printed = true;
}
}
if count > 0 && trailing_hardbreak && !is_inline {
if printed && trailing_hardbreak && !is_inline {
self.hardbreak_if_not_bol();
}
printed
}

fn print_attribute(&mut self, attr: &ast::Attribute) {
Expand Down Expand Up @@ -1646,7 +1647,7 @@ impl<'a> State<'a> {
self.ann.pre(self, AnnNode::Block(blk));
self.bopen();

self.print_inner_attributes(attrs);
let has_attrs = self.print_inner_attributes(attrs);

for (i, st) in blk.stmts.iter().enumerate() {
match st.kind {
Expand All @@ -1660,7 +1661,7 @@ impl<'a> State<'a> {
}
}

let empty = attrs.is_empty() && blk.stmts.is_empty();
let empty = !has_attrs && blk.stmts.is_empty();
self.bclose_maybe_open(blk.span, empty, close_box);
self.ann.post(self, AnnNode::Block(blk))
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/pretty/attr-fn-inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
fn main() {
#![rustc_dummy]
#[rustc_dummy]
fn f() { }
fn f() {}

#[rustc_dummy]
fn g() { }
fn g() {}
}
4 changes: 2 additions & 2 deletions src/test/pretty/attr-literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
fn main() {
#![rustc_dummy("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
#[rustc_dummy = 8]
fn f() { }
fn f() {}

#[rustc_dummy(1, 2, 3)]
fn g() { }
fn g() {}
}
2 changes: 1 addition & 1 deletion src/test/pretty/attr-tokens-raw-ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
// pp-exact

#[rustfmt::r#final(final)]
fn main() { }
fn main() {}
2 changes: 1 addition & 1 deletion src/test/pretty/delimited-token-groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ mac! {
}]
#[rustc_dummy =
"aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa"]
fn main() { }
fn main() {}
10 changes: 5 additions & 5 deletions src/test/pretty/doc-comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// some single-line non-doc comment

/// some single line outer-docs
fn a() { }
fn a() {}

fn b() {
//! some single line inner-docs
Expand All @@ -17,7 +17,7 @@ fn b() {
//////////////////////////////////
/// some single-line outer-docs preceded by a separator
/// (and trailing whitespaces)
fn c() { }
fn c() {}

/*
* some multi-line non-doc comment
Expand All @@ -26,7 +26,7 @@ fn c() { }
/**
* some multi-line outer-docs
*/
fn d() { }
fn d() {}

fn e() {
/*!
Expand All @@ -43,10 +43,10 @@ fn e() {
/**
* some multi-line outer-docs preceded by a separator
*/
fn f() { }
fn f() {}

#[doc = "unsugared outer doc-comments work also"]
fn g() { }
fn g() {}

fn h() {
#![doc = "as do inner ones"]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn test_expr() {
#[attr]
{}
),
"#[attr] { }", // FIXME
"#[attr] {}",
);
assert_eq!(
stringify_expr!(
Expand Down