1 type Noncopyable = Box<isize>;
2
3
4
5 struct Foo {
6 copied: isize,
7 moved: Box<isize>,
8 noncopyable: Noncopyable
9 }
10
test0(f: Foo, g: Noncopyable, h: Noncopyable)11 fn test0(f: Foo, g: Noncopyable, h: Noncopyable) {
12 // just copy implicitly copyable fields from `f`, no moves:
13 let _b = Foo {moved: Box::new(1), noncopyable: g, ..f};
14 let _c = Foo {moved: Box::new(2), noncopyable: h, ..f};
15 }
16
test1(f: Foo, g: Noncopyable, h: Noncopyable)17 fn test1(f: Foo, g: Noncopyable, h: Noncopyable) {
18 // copying move-by-default fields from `f`, so move:
19 let _b = Foo {noncopyable: g, ..f};
20 let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved`
21 }
22
main()23 fn main() {}
24