Incorrect partially moved value error check when pattern matching boxed structures. · Issue #16223 · rust-lang/rust (original) (raw)
The following code worked on 0.11
bu no longer works on master
. Last known good nightly was August 1st.
struct Foo { a: Vec, b: Vec }
fn main() { let foo = box Foo{a: Vec::new(), b: Vec::new()}; let Foo { a: a, b: b } = *foo; }
This will create the following error message:
<anon>:8:24: 8:25 error: use of partially moved value: `foo.b`
<anon>:8 let Foo { a: a, b: b } = *foo;
^
<anon>:8:18: 8:19 note: `foo.a` moved here because it has type `collections::vec::Vec<u8>`, which is moved by default (use `ref` to override)
<anon>:8 let Foo { a: a, b: b } = *foo;
If Foo
is not boxed this will function correctly.
struct Foo { a: Vec, b: Vec }
fn main() { let foo = Foo{a: Vec::new(), b: Vec::new()}; let Foo { a: a, b: b } = foo; }