mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
d68f2a6b71
``` error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:7:9 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | - move occurs because `t` has type `T`, which does not implement the `Copy` trait ... LL | (t, t) | - ^ value used here after move | | | value moved here | help: if `T` implemented `Clone`, you could clone the value --> $DIR/use_of_moved_value_copy_suggestions.rs:4:16 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | ^ consider constraining this type parameter with `Clone` ... LL | (t, t) | - you could clone this value help: consider restricting type parameter `T` | LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) { | ++++++ ``` The `help` is new. On ADTs, we also extend the output with span labels: ``` error[E0507]: cannot move out of static item `FOO` --> $DIR/issue-17718-static-move.rs:6:14 | LL | let _a = FOO; | ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> $DIR/issue-17718-static-move.rs:1:1 | LL | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let _a = FOO; | --- you could clone this value help: consider borrowing here | LL | let _a = &FOO; | + ```
85 lines
4.0 KiB
Plaintext
85 lines
4.0 KiB
Plaintext
warning: byte slice in a packed struct that derives a built-in trait
|
|
--> $DIR/deriving-with-repr-packed.rs:31:5
|
|
|
|
|
LL | #[derive(Debug)]
|
|
| ----- in this derive macro expansion
|
|
...
|
|
LL | data: [u8],
|
|
| ^^^^^^^^^^
|
|
|
|
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
= note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457>
|
|
= help: consider implementing the trait by hand, or remove the `packed` attribute
|
|
= note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default
|
|
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
warning: string slice in a packed struct that derives a built-in trait
|
|
--> $DIR/deriving-with-repr-packed.rs:41:5
|
|
|
|
|
LL | #[derive(Debug)]
|
|
| ----- in this derive macro expansion
|
|
...
|
|
LL | data: str,
|
|
| ^^^^^^^^^
|
|
|
|
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
= note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457>
|
|
= help: consider implementing the trait by hand, or remove the `packed` attribute
|
|
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error[E0507]: cannot move out of `self` which is behind a shared reference
|
|
--> $DIR/deriving-with-repr-packed.rs:22:10
|
|
|
|
|
LL | #[derive(Debug, Default)]
|
|
| ----- in this derive macro expansion
|
|
LL | #[repr(packed)]
|
|
LL | struct X(Y);
|
|
| ^ move occurs because `self.0` has type `Y`, which does not implement the `Copy` trait
|
|
|
|
|
note: if `Y` implemented `Clone`, you could clone the value
|
|
--> $DIR/deriving-with-repr-packed.rs:16:1
|
|
|
|
|
LL | struct Y(usize);
|
|
| ^^^^^^^^ consider implementing `Clone` for this type
|
|
...
|
|
LL | struct X(Y);
|
|
| - you could clone this value
|
|
= note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
|
|
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: aborting due to 1 previous error; 2 warnings emitted
|
|
|
|
For more information about this error, try `rustc --explain E0507`.
|
|
Future incompatibility report: Future breakage diagnostic:
|
|
warning: byte slice in a packed struct that derives a built-in trait
|
|
--> $DIR/deriving-with-repr-packed.rs:31:5
|
|
|
|
|
LL | #[derive(Debug)]
|
|
| ----- in this derive macro expansion
|
|
...
|
|
LL | data: [u8],
|
|
| ^^^^^^^^^^
|
|
|
|
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
= note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457>
|
|
= help: consider implementing the trait by hand, or remove the `packed` attribute
|
|
= note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default
|
|
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
Future breakage diagnostic:
|
|
warning: string slice in a packed struct that derives a built-in trait
|
|
--> $DIR/deriving-with-repr-packed.rs:41:5
|
|
|
|
|
LL | #[derive(Debug)]
|
|
| ----- in this derive macro expansion
|
|
...
|
|
LL | data: str,
|
|
| ^^^^^^^^^
|
|
|
|
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
= note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457>
|
|
= help: consider implementing the trait by hand, or remove the `packed` attribute
|
|
= note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default
|
|
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|