]> git.proxmox.com Git - rustc.git/blame - src/test/ui/noncopyable-class.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / noncopyable-class.rs
CommitLineData
223e47cc
LB
1// Test that a class with a non-copyable field can't be
2// copied
1a4d82fc 3
85aaf69f 4#[derive(Debug)]
0731742a 5struct Bar {
1a4d82fc 6 x: isize,
223e47cc
LB
7}
8
0731742a 9impl Drop for Bar {
1a4d82fc 10 fn drop(&mut self) {}
223e47cc
LB
11}
12
0731742a
XL
13fn bar(x:isize) -> Bar {
14 Bar {
223e47cc
LB
15 x: x
16 }
17}
18
85aaf69f 19#[derive(Debug)]
0731742a 20struct Foo {
1a4d82fc 21 i: isize,
0731742a 22 j: Bar,
223e47cc
LB
23}
24
0731742a
XL
25fn foo(i:isize) -> Foo {
26 Foo {
223e47cc
LB
27 i: i,
28 j: bar(5)
29 }
30}
31
32fn main() {
33 let x = foo(10);
d9579d0f 34 let _y = x.clone(); //~ ERROR no method named `clone` found
1a4d82fc 35 println!("{:?}", x);
223e47cc 36}