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

Rustfmt for<'a> async correctly #131657

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Oct 13, 2024

In #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 #131649

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 13, 2024
@compiler-errors compiler-errors marked this pull request as ready for review October 15, 2024 14:22
@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2024

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@compiler-errors
Copy link
Member Author

r? @ytmimi or @calebcartwright

(doing this PR on top of rust-lang/rust since i don't know when the next subtree sync is, and I'm looking to stabilize in the next few months.)

@ytmimi
Copy link
Contributor

ytmimi commented Oct 15, 2024

@compiler-errors we can do a sync relatively soon. Definitely within the next few months. We'll need to do a sync once style_edition 2024 is stabilized. Could you move this PR over to rustfmt?

@compiler-errors
Copy link
Member Author

@ytmimi: Given the fact that this is affecting users on nightly (see the linked issue -- rustfmt rewrites the code to not compile anymore), I'd like to perform the subtree sync immediately or land it here.

@compiler-errors
Copy link
Member Author

Like, I'm happy to do anything in my power to help accelerate this process (prepare the subtree pushes, resolve any merge conflicts, etc) but I frankly think that waiting months to fix this issue is a very bad experience for users of async closures :)

@ytmimi
Copy link
Contributor

ytmimi commented Oct 15, 2024

Given that extra context I'm happy to merge here.

Async closures are still unstable, right? So this is only impacting users who're opting into the feature? Also, I'm wondering if it's possible for the rustfmt team to be notified about these types of syntax changes to hopefully catch some of these issues earlier on in the process

@compiler-errors
Copy link
Member Author

Async closures are still unstable, right? So this is only impacting users who're opting into the feature?

Correct.

Also, I'm wondering if it's possible for the rustfmt team to be notified about these types of syntax changes to hopefully catch some of these issues earlier on in the process

Yeah, it was an oversight when implementing #127054, otherwise I would've probably included the rustfmt changes directly in that PR.

@ytmimi
Copy link
Contributor

ytmimi commented Oct 15, 2024

Yeah, it was an oversight when implementing #127054, otherwise I would've probably included the rustfmt changes directly in that PR.

Totally understandable. We only get notified if the rustfmt tree is modified so I'm wondering if there's an easy way to communicate syntax changes to the team.

@compiler-errors
Copy link
Member Author

@bors r=ytmimi

@bors
Copy link
Contributor

bors commented Oct 16, 2024

📌 Commit dca646a has been approved by ytmimi

It is now in the queue for this repository.

@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 Oct 16, 2024
Urgau added a commit to Urgau/rust that referenced this pull request 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 added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2024
Rollup of 10 pull requests

Successful merges:

 - rust-lang#129181 (Pass end position of span through inline ASM cookie)
 - rust-lang#130989 (Don't check unsize goal in MIR validation when opaques remain)
 - rust-lang#131657 (Rustfmt `for<'a> async` correctly)
 - rust-lang#131691 (Delay ambiguous intra-doc link resolution after `Cache` has been populated)
 - rust-lang#131730 (Refactor some `core::fmt` macros)
 - rust-lang#131751 (Rename `can_coerce` to `may_coerce`, and then structurally resolve correctly in the probe)
 - rust-lang#131753 (Unify `secondary_span` and `swap_secondary_and_primary` args in `note_type_err`)
 - rust-lang#131776 (Emscripten: Xfail backtrace ui tests)
 - rust-lang#131777 (Fix trivially_copy_pass_by_ref in stable_mir)
 - rust-lang#131778 (Fix needless_lifetimes in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
@calebcartwright
Copy link
Member

I don't have any concerns with this PR being made in-tree here, and in general there's no concerns with urgent fixes being made here; I've fixed a few rustfmt bugs myself here when urgency warranted.

I would, however, push back on the implied characterization of how we'd hypothetically have addressed this. Yes, it's true we don't do syncs on a regular cadence, and sometimes we will go quite a while without doing a sync. However, every time there's been an issue of priority or urgency brought to our attention, we address it promptly and can and do perform syncs over timespans measured in hours or days, not months.

There are multiple pain points and friction we experience during syncs, and while we are working on addressing those we don't do a full sync unless and until we've crossed a threshold that warrants it (which could be an accumulation of enough worthwhile features, minor bug fixes, etc., or a high priority item needing urgent attention).

But we shouldn't conflate those timelines with our readiness and willingness to take action to deal with time sensitive issues.

@calebcartwright
Copy link
Member

Yeah, it was an oversight when implementing #127054, otherwise I would've probably included the rustfmt changes directly in that PR.

Totally understandable. We only get notified if the rustfmt tree is modified so I'm wondering if there's an easy way to communicate syntax changes to the team.

I can't see any path to this via the existing notification mechanisms, and there will always be some surface for AST changes to be made which won't break rustfmt.

I think it's okay for this potential to exist with nightly features and a quick turn around to resolve them, and the only other approach I could think of to help prevent them would be more process oriented in nature (e.g. a snippet with the new/modified syntax being added to rustfmt tests under tests/target/..)

@compiler-errors
Copy link
Member Author

compiler-errors commented Oct 16, 2024

I can't see any path to this via the existing notification mechanisms, and there will always be some surface for AST changes to be made which won't break rustfmt.

Yeah. If we tracked the grammar more formally (with a grammar specification or something -- specifically, separately from the parser) the perhaps rustfmt or style could be modified everytime that gets changed, but currently that isn't so.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#130989 (Don't check unsize goal in MIR validation when opaques remain)
 - rust-lang#131657 (Rustfmt `for<'a> async` correctly)
 - rust-lang#131691 (Delay ambiguous intra-doc link resolution after `Cache` has been populated)
 - rust-lang#131730 (Refactor some `core::fmt` macros)
 - rust-lang#131751 (Rename `can_coerce` to `may_coerce`, and then structurally resolve correctly in the probe)
 - rust-lang#131753 (Unify `secondary_span` and `swap_secondary_and_primary` args in `note_type_err`)
 - rust-lang#131776 (Emscripten: Xfail backtrace ui tests)
 - rust-lang#131777 (Fix trivially_copy_pass_by_ref in stable_mir)
 - rust-lang#131778 (Fix needless_lifetimes in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 950fb62 into rust-lang:master Oct 16, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustfmt reorders for and async in impl for<'chk> async Fn
5 participants