]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/moves-sru-moved-field.rs
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / ui / moves / moves-sru-moved-field.rs
1 type Noncopyable = Box<isize>;
2
3
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::new(1), noncopyable: g, ..f};
14     let _c = Foo {moved: Box::new(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() {}