Open
Description
Code
#[derive(Debug)]
pub(crate) struct UInt16LE {
bytes: [u8; 2],
}
#[derive(Debug)]
#[repr(C, packed)]
pub(crate) struct Header {
version: u8,
kind: UInt16LE,
}
Current output
error[E0507]: cannot move out of `self.kind` which is behind a shared reference
--> src/lib.rs:11:5
|
7 | #[derive(Debug)]
| ----- in this derive macro expansion
...
11 | kind: UInt16LE,
| ^^^^^^^^^^^^^^ move occurs because `self.kind` has type `UInt16LE`, which does not implement the `Copy` trait
|
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
Desired output
"cannot form reference to `self.kind` because struct `Header` is `repr(packed)`"
"note: `self.kind` has type `UInt16LE`, which does not implement the `Copy` trait"
Rationale and extra context
I thought this was a regression in 1.69, and it sort of was, but presumably the old code was incorrect, since you can't form a reference to a field in a repr(packed)
struct. Nothing in the diagnostic pointed me to that, though, so I had to figure out why this struct was different.
Other cases
No response
Anything else?
No response