summary refs log tree commit diff
path: root/src/test/compile-fail/noncopyable-class.rs
blob: 33aef1c0a724391dc9ac8f883867cb088b863a30 (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
// error-pattern: copying a noncopyable value

// Test that a class with a non-copyable field can't be
// copied
struct bar {
  x: int,
  drop {}
}

fn bar(x:int) -> bar {
    bar {
        x: x
    }
}

struct foo {
  i: int,
  j: bar,
}

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

fn main() { let x <- foo(10); let y = x; log(error, x); }