Closed
Description
The following code causes a compilation error.
#[repr(packed)]
#[derive(Debug)]
struct B(String);
fn main(){}
Error
error[E0507]: cannot move out of `self` which is behind a shared reference
--> src/main.rs:4:10
|
3 | #[derive(Debug)]
| ----- in this derive macro expansion
4 | struct B(String);
| ^^^^^^ move occurs because `self.0` has type `String`, 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)
For more information about this error, try `rustc --explain E0507`.
Meta
rustc --version --verbose
:
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2