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

Attempting to run an async fn after completion mentions generators #65419

Closed
Nemo157 opened this issue Oct 14, 2019 · 8 comments
Closed

Attempting to run an async fn after completion mentions generators #65419

Nemo157 opened this issue Oct 14, 2019 · 8 comments
Assignees
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Oct 14, 2019

If a user attempts to do something like this (playground including trivial executor):

async fn foo() {
}

fn main() {
    let mut future = Box::pin(foo());
    executor::block_on(future.as_mut());
    executor::block_on(future.as_mut());
}

they get a panic talking about generators:

thread 'main' panicked at 'generator resumed after completion', src/main.rs:1:16

This issue has been assigned to @ninjasource via this comment.

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2019
@nikomatsakis nikomatsakis added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Oct 15, 2019
@nikomatsakis
Copy link
Contributor

Hey @Zoxc -- where does this error come from, anyway? A quick ripgrep of the source didn't find an obvious source.

@nikomatsakis
Copy link
Contributor

Is it from the Display impl for PanicInfo?

@Centril
Copy link
Contributor

Centril commented Oct 15, 2019

@Zoxc
Copy link
Contributor

Zoxc commented Oct 15, 2019

Yeah that's it.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 15, 2019

OK, yes, that's what I meant. So to fix this we presumably want to:

  • Add a new PanicInfo variant with a different description
  • Use that PanicInfo variant for generators that arose from async fn

We would need to get access to the generator_kind for this generator in this function here;

fn create_generator_resume_function<'tcx>(
tcx: TyCtxt<'tcx>,
transform: TransformVisitor<'tcx>,
def_id: DefId,
source: MirSource<'tcx>,
body: &mut Body<'tcx>,
) {

Right now, I don't think that is stored in the MIR, but we could easily do do (I'd rather not retrieve it from the HIR).

Sound about right?

@ninjasource
Copy link

@rustbot claim

@rustbot rustbot self-assigned this Oct 22, 2019
@ninjasource
Copy link

Hi @nikomatsakis, that makes sense. I'll lean on @gilescope for initial guidance on this and I'll add more comments after I dig a little deeper. Cheers, David

bors added a commit that referenced this issue Nov 29, 2019
…r=oli-obk

Async fn resume after completion

#65419 -- Attempting to run an async fn after completion mentions generators
Not yet ready for review - work in progress
Just need to run the tests on a proper build server
bors added a commit that referenced this issue Nov 29, 2019
…r=oli-obk

Async fn resume after completion

#65419 -- Attempting to run an async fn after completion mentions generators
Not yet ready for review - work in progress
Just need to run the tests on a proper build server
@gilescope
Copy link
Contributor

@tmandry we can close this one - @ninjasource has fixed this.

@Nemo157 Nemo157 closed this as completed Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants