forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#97664 - estebank:suggest-bound-derive-copy,…
… r=compiler-errors On E0204 suggest missing type param bounds ``` error[E0204]: the trait `Copy` may not be implemented for this type --> f42.rs:9:17 | 9 | #[derive(Debug, Copy, Clone)] | ^^^^ 10 | pub struct AABB<K>{ 11 | pub loc: Vector2<K>, | ------------------- this field does not implement `Copy` 12 | pub size: Vector2<K> | -------------------- this field does not implement `Copy` | note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` --> f42.rs:11:5 | 11 | pub loc: Vector2<K>, | ^^^^^^^^^^^^^^^^^^^ note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` --> f42.rs:12:5 | 12 | pub size: Vector2<K> | ^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `K` | 10 | pub struct AABB<K: Debug>{ | +++++++ ``` Fix rust-lang#89137.
- Loading branch information
Showing
12 changed files
with
219 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-2.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// run-rustfix | ||
use std::fmt::Debug; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Vector2<T: Debug + Copy + Clone>{ | ||
pub x: T, | ||
pub y: T | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct AABB<K: Debug + std::marker::Copy>{ | ||
pub loc: Vector2<K>, //~ ERROR the trait bound `K: Copy` is not satisfied | ||
pub size: Vector2<K> | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// run-rustfix | ||
use std::fmt::Debug; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Vector2<T: Debug + Copy + Clone>{ | ||
pub x: T, | ||
pub y: T | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct AABB<K: Debug>{ | ||
pub loc: Vector2<K>, //~ ERROR the trait bound `K: Copy` is not satisfied | ||
pub size: Vector2<K> | ||
} | ||
|
||
fn main() {} |
19 changes: 19 additions & 0 deletions
19
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0277]: the trait bound `K: Copy` is not satisfied | ||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:12:14 | ||
| | ||
LL | pub loc: Vector2<K>, | ||
| ^^^^^^^^^^ the trait `Copy` is not implemented for `K` | ||
| | ||
note: required by a bound in `Vector2` | ||
--> $DIR/missing-bound-in-derive-copy-impl-2.rs:5:31 | ||
| | ||
LL | pub struct Vector2<T: Debug + Copy + Clone>{ | ||
| ^^^^ required by this bound in `Vector2` | ||
help: consider further restricting this bound | ||
| | ||
LL | pub struct AABB<K: Debug + std::marker::Copy>{ | ||
| +++++++++++++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
16 changes: 16 additions & 0 deletions
16
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//run-rustfix | ||
use std::fmt::Debug; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Vector2<T: Debug + Copy + Clone>{ | ||
pub x: T, | ||
pub y: T | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type | ||
pub struct AABB<K: Copy + Debug>{ | ||
pub loc: Vector2<K>, | ||
pub size: Vector2<K> | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//run-rustfix | ||
use std::fmt::Debug; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Vector2<T: Debug + Copy + Clone>{ | ||
pub x: T, | ||
pub y: T | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type | ||
pub struct AABB<K: Copy>{ | ||
pub loc: Vector2<K>, | ||
pub size: Vector2<K> | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
src/test/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0204]: the trait `Copy` may not be implemented for this type | ||
--> $DIR/missing-bound-in-derive-copy-impl-3.rs:10:17 | ||
| | ||
LL | #[derive(Debug, Copy, Clone)] | ||
| ^^^^ | ||
LL | pub struct AABB<K: Copy>{ | ||
LL | pub loc: Vector2<K>, | ||
| ------------------- this field does not implement `Copy` | ||
LL | pub size: Vector2<K> | ||
| -------------------- this field does not implement `Copy` | ||
| | ||
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` | ||
--> $DIR/missing-bound-in-derive-copy-impl-3.rs:12:5 | ||
| | ||
LL | pub loc: Vector2<K>, | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | pub size: Vector2<K> | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider further restricting this bound | ||
| | ||
LL | pub struct AABB<K: Copy + Debug>{ | ||
| +++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0204`. |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/missing-bound-in-derive-copy-impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use std::fmt::Debug; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct Vector2<T: Debug + Copy + Clone>{ | ||
pub x: T, | ||
pub y: T | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type | ||
pub struct AABB<K>{ | ||
pub loc: Vector2<K>, | ||
pub size: Vector2<K> | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
src/test/ui/suggestions/missing-bound-in-derive-copy-impl.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0204]: the trait `Copy` may not be implemented for this type | ||
--> $DIR/missing-bound-in-derive-copy-impl.rs:9:17 | ||
| | ||
LL | #[derive(Debug, Copy, Clone)] | ||
| ^^^^ | ||
LL | pub struct AABB<K>{ | ||
LL | pub loc: Vector2<K>, | ||
| ------------------- this field does not implement `Copy` | ||
LL | pub size: Vector2<K> | ||
| -------------------- this field does not implement `Copy` | ||
| | ||
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` | ||
--> $DIR/missing-bound-in-derive-copy-impl.rs:11:5 | ||
| | ||
LL | pub loc: Vector2<K>, | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | pub size: Vector2<K> | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider restricting type parameter `K` | ||
| | ||
LL | pub struct AABB<K: Debug>{ | ||
| +++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0204`. |