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 nicer async/await trait errors for generators in any place in the error 'stack' #67116

Closed

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Dec 7, 2019

Fixes #67025

Currently, we only print 'nice' async/await trait errors when the 'bad' type inside the generator occurs at the top of the 'stack' of errors (the nested errors in the ObligationCauseCode.

This PR allows these 'nice' error messages to be printed each time we encounter a generator in the error stack. This has the result of showing the user how each async fn contributed to the overall type not implementing some auto trait.

This PR still has a few issues:

  • The errors have some unnecessary 'occurs within GenFuture/impl Future/[static generator]. It would be nice to try to completely eliminate these when it doesn't reduce clarity, as they often add no actual information.
  • We should be printing an additional 'nice' error in the test issue-64130-non-send-future-diags.rs, for async fn foo. I suspect that some of the involved lifetimes are causing a false negative when we check if a type occurs within the generator.

However, I'd be interested in feedback on the overall idea of displaying multiple spans in the error message.

cc @estebank

@rust-highfive
Copy link
Collaborator

r? @cramertj

(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 7, 2019
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@estebank

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@nikomatsakis
Copy link
Contributor

How does this compare against #65345 ?

@Aaron1011
Copy link
Member Author

@nikomatsakis: #65345 doesn't appear to handle multiple generator in the same error stack, but it has more diagnostic improvements for when it does detect a generator.

@nikomatsakis
Copy link
Contributor

@Aaron1011

OK. How would you feel about landing #65345 first, and trying to rebase this atop that?

@Aaron1011
Copy link
Member Author

@nikomatsakis: Sounds good to me

@bors

This comment has been minimized.

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@Aaron1011

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@Aaron1011 Aaron1011 marked this pull request as ready for review December 12, 2019 23:58
@Mark-Simulacrum
Copy link
Member

Hm, maybe we can work around that? (Environment variable or something) It also seems plausibly not bad. Maybe even just giving an issue link without the switching and asking for feedback is good (it's sort of like the survey suggested by Niko, but maybe a bit easier).

@Aaron1011
Copy link
Member Author

Maybe even just giving an issue link without the switching and asking for feedback is good (it's sort of like the survey suggested by Niko, but maybe a bit easier).

Without actually showing the intermediate spans, I'm not sure how useful that would be. If showing that information would end up being distracting and not very useful, this we wouldn't find out by just giving an issue link. Conversely, users might not realize that showing extra spans would be helpful, since they don't know what they would be seeing for their particular error.

@JohnCSimon JohnCSimon 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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2020
@JohnCSimon
Copy link
Member

triage: merge conflicts

@Aaron1011
Copy link
Member Author

Aaron1011 commented Jan 19, 2020

@JohnCSimon: This PR is currently blocked on reaching some kind of consensus as to what these kinds of errors should look like:

  • "Intermediate" frames are always hidden
  • "Intermediate" frames are hidden by default, can be displayed via a compiler flag
  • Something else

@nikomatsakis nikomatsakis added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 24, 2020
@nikomatsakis
Copy link
Contributor

@Aaron1011 do you think you could prepare a hackmd or gist that summarizes the question at hand? It would be great to give some example programs along with two sample outputs, for example. I would like to focus the discussion on very specific examples and proposals. I'd also like to get this resolved. =)

@nikomatsakis nikomatsakis added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed I-nominated S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2020
@nikomatsakis
Copy link
Contributor

OK, I prepared a summary of the question at hand -- does this sound like it captures the question

@nikomatsakis
Copy link
Contributor

I was thinking of starting an internals thread to drive this to a conclusion

@nikomatsakis
Copy link
Contributor

Created internals thread here

@nikomatsakis
Copy link
Contributor

We discussed this in our compiler team triage meeting. The internals thread seems to have died down somewhat but the polling at least suggests a preference for "minimal stack trace" (72%).

There is definitely some interest in a "verbose mode" as well. But we felt that would best be preferred as a separate consideration.

@Aaron1011 do you think you could explore altering the PR to give a more "minimal stack trace"? We'll have to experiment a bit with the best way to format that, I imagine.

@pnkfelix
Copy link
Member

pnkfelix commented Mar 4, 2020

Here a link to aforementioned discussion amongst T-compiler.

Based on niko's comment above, I am shifting this to S-waiting-on-author instead of team.

@pnkfelix pnkfelix 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-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Mar 4, 2020
@joelpalmer joelpalmer 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 23, 2020
@joelpalmer joelpalmer 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 2, 2020
@joelpalmer joelpalmer 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 14, 2020
@Dylan-DPC-zz
Copy link

@Aaron1011 any updates on this?

@crlf0710 crlf0710 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 24, 2020
@nikomatsakis
Copy link
Contributor

I'm going to close this PR, just to keep my list tidy -- @Aaron1011 please feel free to re-open if it's adjusted. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Reduce type errors in async fns