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

Comments

@Nemo157
Copy link
Member

@Nemo157 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.

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Oct 15, 2019

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

@nikomatsakis nikomatsakis commented Oct 15, 2019

Is it from the Display impl for PanicInfo?

@Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Oct 15, 2019

Yeah that's it.

@nikomatsakis
Copy link
Contributor

@nikomatsakis 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

@ninjasource ninjasource commented Oct 22, 2019

@rustbot claim

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

@ninjasource ninjasource commented Oct 22, 2019

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 26, 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 26, 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
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

@gilescope gilescope commented Feb 11, 2020

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

@Nemo157 Nemo157 closed this Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants