]> git.lizzy.rs Git - rust.git/blob - src/test/ui/moves/moves-sru-moved-field.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / moves / moves-sru-moved-field.rs
1 #![feature(box_syntax)]
2
3 type Noncopyable = Box<isize>;
4
5 struct Foo {
6     copied: isize,
7     moved: Box<isize>,
8     noncopyable: Noncopyable
9 }
10
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 1, noncopyable: g, ..f};
14     let _c = Foo {moved: box 2, noncopyable: h, ..f};
15 }
16
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
23 fn main() {}