about summary refs log tree commit diff
path: root/tests/ui/async-await/drop-live-upvar.rs
blob: 8e881f729b9102edbfb35475364f8159b334a2e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ edition: 2018
// Regression test for <https://github.com/rust-lang/rust/issues/144155>.

struct NeedsDrop<'a>(&'a Vec<i32>);

async fn await_point() {}

impl Drop for NeedsDrop<'_> {
    fn drop(&mut self) {}
}

fn foo() {
    let v = vec![1, 2, 3];
    let x = NeedsDrop(&v);
    let c = async {
        std::future::ready(()).await;
        drop(x);
    };
    drop(v);
    //~^ ERROR cannot move out of `v` because it is borrowed
}

fn main() {}