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

Coroutine resume type is not borrow-checked #119564

Closed
compiler-errors opened this issue Jan 4, 2024 · 0 comments · Fixed by #119563
Closed

Coroutine resume type is not borrow-checked #119564

compiler-errors opened this issue Jan 4, 2024 · 0 comments · Fixed by #119563
Labels
A-borrow-checker Area: The borrow checker A-coroutines Area: Coroutines A-NLL Area: Non Lexical Lifetimes (NLL) C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Jan 4, 2024

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 ❗

@compiler-errors compiler-errors added A-borrow-checker Area: The borrow checker I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness A-NLL Area: Non Lexical Lifetimes (NLL) C-bug Category: This is a bug. A-coroutines Area: Coroutines F-coroutines `#![feature(coroutines)]` requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Jan 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 4, 2024
@compiler-errors compiler-errors removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 4, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2024
…r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes rust-lang#119564

r? types
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2024
…r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes rust-lang#119564

r? types
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2024
…r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes rust-lang#119564

r? types
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2024
…r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes rust-lang#119564

r? types
@bors bors closed this as completed in ad7aabd Jan 5, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 5, 2024
Rollup merge of rust-lang#119563 - compiler-errors:coroutine-resume, r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes rust-lang#119564

r? types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-coroutines Area: Coroutines A-NLL Area: Non Lexical Lifetimes (NLL) C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants