-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing a moved struct #26665
Comments
/cc @rust-lang/lang This isn't unsafe or anything, but we may want to change that? Or have a diagnostic of some kind? |
Local variables are semantically memory locations on the stack, which can own values. Move semantics means that something like It would be unsafe if Closing as not-a-bug, but thanks for filing! |
Thanks for the explanation! |
I was very surprised that this code compiles and outputs
1
. When I try to printa.val
after the assignment I get a compile error -- as I expected.Assuming A has move semantics, this should IMHO never compile ... and/or, (according to my newbie mental model of move semantics) output a 2.
The text was updated successfully, but these errors were encountered: