Skip to content

Coroutine resume type is not borrow-checked #119564

Closed
@compiler-errors

Description

@compiler-errors

I tried this code:

#![feature(coroutine_trait)]
#![feature(coroutines)]

use std::ops::Coroutine;

struct Invariant<'a>(fn(&'a ()) -> &'a ());

fn x<'a, 'b>() -> impl Coroutine<Invariant<'a>> {
    |_: Invariant<'a>| {
        let a: Invariant<'b> = yield ();
    }
}

I expected to see compilation fail, since Invariant<'a> is not a subtype of Invariant<'b>.

Instead, compilation succeeded ❗

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerA-coroutinesArea: CoroutinesC-bugCategory: This is a bug.F-coroutines`#![feature(coroutines)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-typesRelevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions