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
enumX{A(String,Box<X>),}fnfoo(x:Box<X>){letX::A(a, b) = *x;}
The compiler says that extracting b is a "use of moved value: x", and that x was moved when extracting a. The issue also occurs if using match, or when using the box_patterns feature. However, this clearly should be legal to do.
The following code also breaks in a similar way, but with a different error message ("use of collaterally moved value: (x:X::A).1"; which is not even mentioned by --explain E0382):
enumX{A(String,Box<X>),C,}fnfoo(x:Box<X>){ifletX::A(a, b) = *x {}}
It was pointed out on IRC that this can be worked around by writing {*x} instead of *x, but that's not particularly satisfactory. Someone then said that this was likely a bug with the deref-move special case for Box, where it doesn't handle partial moves correctly.
The text was updated successfully, but these errors were encountered:
On stable, the following code does not compile:
The compiler says that extracting
b
is a "use of moved value:x
", and thatx
was moved when extractinga
. The issue also occurs if usingmatch
, or when using thebox_patterns
feature. However, this clearly should be legal to do.The following code also breaks in a similar way, but with a different error message ("use of collaterally moved value:
(x:X::A).1
"; which is not even mentioned by--explain E0382
):It was pointed out on IRC that this can be worked around by writing
{*x}
instead of*x
, but that's not particularly satisfactory. Someone then said that this was likely a bug with the deref-move special case forBox
, where it doesn't handle partial moves correctly.The text was updated successfully, but these errors were encountered: