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
struct NonCopyable {
x: (),
f: NonCopyable2
}
struct NonCopyable2 {
g: ()
}
impl NonCopyable2: Drop {
fn finalize(&self) { }
}
fn main() {
let a = NonCopyable { x: (), f: NonCopyable2 { g: () } };
let b = NonCopyable {
x: (),
.. a
};
}
/home/brian/dev/rust/src/test/run-pass/test.rs:16:8: 16:11 warning: unused variable: `b`
/home/brian/dev/rust/src/test/run-pass/test.rs:16 let b = NonCopyable {
^~~
/home/brian/dev/rust/src/test/run-pass/test.rs:16:12: 16:23 error: copying a noncopyable value
/home/brian/dev/rust/src/test/run-pass/test.rs:16 let b = NonCopyable {
^~~~~~~~~~~
error: aborting due to previous error
One of the fields in a is noncopyable and doesn't get moved into b. I think this should work as written, but if not then the error message should be better.
The text was updated successfully, but these errors were encountered:
The message is wrong but not for the reason you suggest. You are copying the field f from a which is non-copyable.
However, in fact I believe that a should be being moved here, which means that you are actually moving the field f from a which should be ok.
When doing my recent patch, I removed most of these "copyability" checks from kind.rs for this reason (that is, those copies would not actually be moves if the type were non-copyable) but I left this one. However, I think there is no need at all to check whether the base is non-copyable.
One of the fields in
a
is noncopyable and doesn't get moved intob
. I think this should work as written, but if not then the error message should be better.The text was updated successfully, but these errors were encountered: