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

Print space after formal generic params in fn type #92372

Merged
merged 1 commit into from
Dec 29, 2021

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Dec 28, 2021

Follow-up to #92238 fixing one of the FIXMEs.

macro_rules! repro {
    ($ty:ty) => {
        stringify!($ty)
    };
}

fn main() {
    println!("{}", repro!(for<'a> fn(&'a u8)));
}

Before: for<'a>fn(&'a u8)
After: for<'a> fn(&'a u8)

The pretty printer's print_formal_generic_params already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space.

fn print_formal_generic_params(&mut self, generic_params: &[ast::GenericParam]) {
if !generic_params.is_empty() {
self.word("for");
self.print_generic_params(generic_params);
self.nbsp();
}
}

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 28, 2021
@rust-highfive
Copy link
Collaborator

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 28, 2021
@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 28, 2021

📌 Commit ad29c17 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 28, 2021
@dtolnay
Copy link
Member Author

dtolnay commented Dec 28, 2021

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 29, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#92075 (rustdoc: Only special case struct fields for intra-doc links, not enum variants)
 - rust-lang#92118 (Parse and suggest moving where clauses after equals for type aliases)
 - rust-lang#92237 (Visit expressions in-order when resolving pattern bindings)
 - rust-lang#92340 (rustdoc: Start cleaning up search index generation)
 - rust-lang#92351 (Add long error explanation for E0227)
 - rust-lang#92371 (Remove pretty printer space inside block with only outer attrs)
 - rust-lang#92372 (Print space after formal generic params in fn type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 949769c into rust-lang:master Dec 29, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 29, 2021
@dtolnay dtolnay deleted the fntype branch December 29, 2021 19:28
@dtolnay dtolnay added the A-pretty Area: Pretty printing (including `-Z unpretty`) label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants