Skip to content

Pretty-print generators with their generator_kind #104931

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

Merged
merged 1 commit into from
Nov 27, 2022

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Nov 26, 2022

After removing GenFuture, I special-cased async generators to pretty-print as impl Future<Output = X> mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as [$async-type@$source-position] in various diagnostics, and updates the tests that this touches.

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2022

r? @eholk

(rustbot has picked a reviewer for you, use r? to override)

@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. labels Nov 26, 2022
@eholk
Copy link
Contributor

eholk commented Nov 26, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 26, 2022

📌 Commit daa4845365c5fce7566063552ee52ec8627fac10 has been approved by eholk

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 Nov 26, 2022
@@ -29,13 +29,13 @@ LL | |
LL | | }
| |_^ expected `u8`, found `()`

error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
error[E0271]: expected `[static `async` block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to be a future that resolves to `()`, but it resolves to `u8`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the nested backticks in `async` is a bit strange looking in these type errors.

Also, I'm not sure if we expect users to know what static generator movability is -- if the generator kind is Async, maybe we could just drop the static (maybe unless we pass in -Zverbose or something)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I pushed an updated version that does this.

Also now uses the descr() method for explicit diagnostics that still print `async` block, but when printing the type of the block itself, the output is cleaner now.

After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$movability `async` $something@$source-position]` in various diagnostics, and updates the tests that this touches.
@Swatinem
Copy link
Contributor Author

Swatinem commented Nov 26, 2022

Another case that could maybe be improved further would be:

error[E0308]: mismatched types
[…]
   = note:     expected struct `Pin<Box<dyn Future<Output = i32> + Send>>`
           found `async` block `[async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6]`

The async block is now redundant, though this is just a minor inconvenience.

@eholk
Copy link
Contributor

eholk commented Nov 26, 2022

@bors r+

Thanks for the improvements!

@bors
Copy link
Collaborator

bors commented Nov 26, 2022

📌 Commit c96d888 has been approved by eholk

It is now in the queue for this repository.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 27, 2022
Pretty-print generators with their `generator_kind`

After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
@matthiaskrgr
Copy link
Member

@bors r- failed in a rollup
#104970 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 27, 2022
@matthiaskrgr
Copy link
Member

Hmm, looks like this was actually not the problem 😅
@bors r=eholk

@bors
Copy link
Collaborator

bors commented Nov 27, 2022

📌 Commit c96d888 has been approved by eholk

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 27, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 27, 2022
Pretty-print generators with their `generator_kind`

After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally.

This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 27, 2022
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#95836 (Use `rust_out{exe_suffix}` for doctests)
 - rust-lang#104882 (notify lcnr on changes to `ObligationCtxt`)
 - rust-lang#104892 (Explain how to get the discriminant out of a `#[repr(T)] enum` with payload)
 - rust-lang#104917 (Allow non-org members to label `requires-debug-assertions`)
 - rust-lang#104931 (Pretty-print generators with their `generator_kind`)
 - rust-lang#104934 (Remove redundant `all` in cfg)
 - rust-lang#104944 (Support unit tests for jsondoclint)
 - rust-lang#104946 (rustdoc: improve popover focus handling JS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6e6c42c into rust-lang:master Nov 27, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 27, 2022
@Swatinem Swatinem deleted the async-pretty branch November 29, 2022 20:29
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants