-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show error E0277 when the trait bound of a struct's member's type is unsatisfied even if E0204 is also present #89137
Comments
That's the exact error from Rust 1.43.0 onward, before that it doesn't say what derive the error comes from. |
The error has gotten (slightly) better on nightly since a recent change of mine:
It only suggests one of the missing bounds, adding |
… 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.
@compiler-errors It would be nice if the |
I'll put it on my to-do list. I'm pretty sure the obligation is just constructed in @rustbot claim |
…rror-spans, r=Dylan-DPC Tighten spans for bad fields in struct deriving `Copy` r? `@estebank` Closes rust-lang#89137 for good, I think Not sure if this is what you were looking for in rust-lang#89137 (comment)
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fbd47fd0a07c3a9a05978696f46aac3d
The current output is:
Ideally the output should look like:
Keeping the other error may or may not make sense, but I propose adding this, as it points more towards how to fix the issue and prevents barking up the tree of how a derive(Copy)'d type can not implement copy (there's a good answer here, but it was not immediately obvious to me upon seeing the original error).
I generated this error message by removing the derive line from the AABB struct.
This bug takes place on beta and nightly according to the Rust playground.
The text was updated successfully, but these errors were encountered: