You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Misleading error message due to Box causing move of struct #56496
structFooInner{value1:Option<String>,value2:Option<String>,}structFoo(Box<FooInner>);fnmain(){let foo = Foo(Box::new(FooInner{value1:Some("Hello World".to_string()),value2:Some("Hello World".to_string()),}));let inner = foo.0;// uncoment this line to fix the error//let inner = *inner;let x = inner.value1;let y = inner.value2;println!("{:?}", x);println!("{:?}", y);}
Error message:
error[E0382]: use of moved value: `inner`
--> src/main.rs:16:9
|
15 | let x = inner.value1;
| - value moved here
16 | let y = inner.value2;
| ^ value used here after move
|
= note: move occurs because `inner.value1` has type `std::option::Option<std::string::String>`, which does not implement the `Copy` trait
I would have expected the compiler informing me that the entire struct was moved due to the box involved.
changed the title [-]Misleading error due to Box causing move of struct[/-][+]Misleading error message due to Box causing move of struct[/+]on Dec 4, 2018
Activity
[-]Misleading error due to Box causing move of struct[/-][+]Misleading error message due to Box causing move of struct[/+]Auto merge of #59114 - matthewjasper:enable-migate-2015, r=<try>
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix