Skip to content
New issue

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

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

Already on GitHub? # to your account

rustfmt reorders for and async in impl for<'chk> async Fn #131649

Closed
nikomatsakis opened this issue Oct 13, 2024 · 2 comments · Fixed by #131657
Closed

rustfmt reorders for and async in impl for<'chk> async Fn #131649

nikomatsakis opened this issue Oct 13, 2024 · 2 comments · Fixed by #131657
Assignees
Labels
A-rustfmt Area: Rustfmt C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]`

Comments

@nikomatsakis
Copy link
Contributor

I tried formatting this code:

#![feature(async_closure)]

async fn my_func(op: impl for<'x> async Fn(&'x String)) {
    let s = String::new();
    op(&s).await
}

fn main() { }

I expected to see this happen: nothing

Instead, this happened: rustfmt reorders for and async incorrectly...

#![feature(async_closure)]

async fn my_func(op: impl async for<'x> Fn(&'x String)) {
    let s = String::new();
    op(&s).await
}

fn main() {}

This formatted code does not compile.

@nikomatsakis nikomatsakis added A-rustfmt Area: Rustfmt C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` labels Oct 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 13, 2024
@nikomatsakis
Copy link
Contributor Author

cc @compiler-errors I imagine this blocks stabilization.

@compiler-errors
Copy link
Member

Ah, I definitely forgot to reorder these bounds after we settled the ordering.

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 13, 2024
@compiler-errors compiler-errors self-assigned this Oct 13, 2024
Urgau added a commit to Urgau/rust that referenced this issue Oct 16, 2024
… r=ytmimi

Rustfmt `for<'a> async` correctly

In rust-lang#127054, we decided to move the trait bound modifier for `async for<'a> Fn()`  to `for<'a> async Fn()`. This wasn't adjusted in rustfmt, so this PR implements that. It also requires consolidating the bound formatting into the `Rewrite` impl for `PolyTraitRef`.

Fixes rust-lang#131649
@bors bors closed this as completed in 950fb62 Oct 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 16, 2024
Rollup merge of rust-lang#131657 - compiler-errors:rustfmt-modifiers, r=ytmimi

Rustfmt `for<'a> async` correctly

In rust-lang#127054, we decided to move the trait bound modifier for `async for<'a> Fn()`  to `for<'a> async Fn()`. This wasn't adjusted in rustfmt, so this PR implements that. It also requires consolidating the bound formatting into the `Rewrite` impl for `PolyTraitRef`.

Fixes rust-lang#131649
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustfmt Area: Rustfmt C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants