summaryrefslogtreecommitdiffstats
path: root/tests/ui/use/use-after-move-self-based-on-type.rs
blob: 9325834954f527689f9993d8fbd0adb273b9130a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct S {
    x: isize,
}

impl Drop for S {
    fn drop(&mut self) {}
}

impl S {
    pub fn foo(self) -> isize {
        self.bar();
        return self.x;  //~ ERROR use of moved value: `self`
    }

    pub fn bar(self) {}
}

fn main() {
    let x = S { x: 1 };
    println!("{}", x.foo());
}