Skip to content

Holding a non-Send Copy type across a yield should be allowed #99104

Closed as not planned
@jyn514

Description

@jyn514

For non-Send types with trivial drop, we still consider them held across the generator, even with -Zdrop-tracking:

async fn trivial_drop() {
    // uncomment to make this program compile
    // {
    let x: *const usize = &0; //~ ERROR has type `*const usize` which is not `Send`
    // }
    async {}.await;
}

fn assert_send<T: Send>(_: T) {}

fn main() {
    assert_send(trivial_drop());
}

There's no reason to do this; *const T has no drop impl and it's not possible to read or write it if it's not explicitly used after the yield.

Originally posted by @jyn514 in #98754 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.T-langRelevant to the language team, which will review and decide on the PR/issue.WG-asyncWorking group: Async & await

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions