Skip to content

-Zdrop-tracking doesn't work if the value is borrowed #101135

Open
@ChayimFriedman2

Description

@ChayimFriedman2

I tried this code with -Zdrop-tracking:

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

struct NonSend(*const ());
fn use_non_send(_: &NonSend) {}

fn main() {
    assert_send(async {
        let non_send = NonSend(&());
        use_non_send(&non_send);
        drop(non_send);
        async {}.await;
    });
}

I expected to see this happen: this should compiler, as -Zdrop-tracking should see that we drop the non-Send type before the yield point.

Instead, this happened: this does not compile with "future cannot be sent between threads safely" pointing to the NonSend type.

If I comment the use_non_send(&non_send); line it works fine.

I don't know if this is supposed to work but this looks like a bug.

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (c07a8b4e0 2022-08-26)
binary: rustc
commit-hash: c07a8b4e09f356c7468b69c50cac7fc5b5000b8a
commit-date: 2022-08-26
host: x86_64-pc-windows-msvc
release: 1.65.0-nightly
LLVM version: 15.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions