Skip to content

Drop tracking misses variables consumed in let statements #93674

Closed
@tmiasko

Description

@tmiasko

For example when compiling with nightly-2022-01-22 (which included drop tracking):

#![feature(generators)]
#![feature(negative_impls)]

struct NotSend;
impl !Send for NotSend {}

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

fn main() {
    // Fails:
    assert_send(|| {
        let a = NotSend;
        let b = a; // a should be consumed here
        drop(b);
        yield;
    });
    // Succeeds:
    assert_send(|| {
        let a;
        a = NotSend;
        let b;
        b = a;
        drop(b);
        yield;
    });
}

This seems to be a mismatch between record_consumed_borrow::ExprUseDelegate which records a consume of a but associates it with a let statement let b = a;, while cfg_build::DropRangeVisitor considers only variables consumed by expressions.

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitA-coroutinesArea: CoroutinesAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions