Skip to content

Underscore binding does not warn about lifetime violation #68502

Closed
@jonhoo

Description

@jonhoo

This code, as expected, fails to compile:

let x = vec![0];
let y = &x[0];
drop(x);
drop(y);

with

error: cannot move out of `x` because it is borrowed

But this code compiles just fine:

let x = vec![0];
let y = &x[0];
drop(x);
let _ = y;

even though y is "used" after its referent has been dropped. Is this expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions