summaryrefslogtreecommitdiffstats
path: root/tests/ui/noncopyable-class.rs
blob: 11b6eb736e9db9e79cac854c5ac31646bce4a1b5 (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
34
35
36
// Test that a class with a non-copyable field can't be
// copied

#[derive(Debug)]
struct Bar {
  x: isize,
}

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

fn bar(x:isize) -> Bar {
    Bar {
        x: x
    }
}

#[derive(Debug)]
struct Foo {
  i: isize,
  j: Bar,
}

fn foo(i:isize) -> Foo {
    Foo {
        i: i,
        j: bar(5)
    }
}

fn main() {
    let x = foo(10);
    let _y = x.clone(); //~ ERROR no method named `clone` found
    println!("{:?}", x);
}