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

Support Rust's Generator feature #416

Closed
avanhatt opened this issue Aug 11, 2021 · 2 comments · Fixed by #1378
Closed

Support Rust's Generator feature #416

avanhatt opened this issue Aug 11, 2021 · 2 comments · Fixed by #1378
Assignees
Labels
[C] Bug This is a bug. Something isn't working. [C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@avanhatt
Copy link
Contributor

avanhatt commented Aug 11, 2021

Rust has a newish Generator type.

We currently fail with unimplemented for this type:

            ty::Generator(_, _, _) => unimplemented!(),

This is used by the popular tokio crate.

@avanhatt avanhatt added [C] Bug This is a bug. Something isn't working. [C] Feature / Enhancement A new feature request or enhancement to an existing feature. labels Aug 11, 2021
@zhassan-aws
Copy link
Contributor

Kani crashes on the following program:

#![feature(generators, generator_trait)]

use std::ops::{Generator, GeneratorState};
use std::pin::Pin;

fn main() {
    let mut generator = || {
        yield 1;
        return "foo"
    };

    match Pin::new(&mut generator).resume(()) {
        GeneratorState::Yielded(1) => {}
        _ => panic!("unexpected return from resume"),
    }
    match Pin::new(&mut generator).resume(()) {
        GeneratorState::Complete("foo") => {}
        _ => panic!("unexpected return from resume"),
    }
}

We should emit an error and exit gracefully until we support this feature.

@zhassan-aws
Copy link
Contributor

Emit an error instead of crash, then remove the "must have" label, and switch "bug" to "feature".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working. [C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants