summaryrefslogtreecommitdiffstats
path: root/tests/ui/moves/move-deref-coercion.rs
blob: 41154388f56a835b8b8fa767a916c6907f6510ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::ops::Deref;

struct NotCopy {
    inner: bool
}

impl NotCopy {
    fn inner_method(&self) {}
}

struct Foo {
    first: NotCopy,
    second: NotCopy
}

impl Deref for Foo {
    type Target = NotCopy;
    fn deref(&self) -> &NotCopy {
        &self.second
    }
}

fn use_field(val: Foo) {
    let _val = val.first;
    val.inner; //~ ERROR borrow of
}

fn use_method(val: Foo) {
    let _val = val.first;
    val.inner_method(); //~ ERROR borrow of
}

fn main() {}