Code
union Union {
member: usize,
}
impl PartialEq<u8> for Union {
fn eq(&self, rhs: &u8) -> bool {
unsafe { self.member == (*rhs).into() }
}
}
fn main() {
assert_eq!(Union { member: 0, }, 0);
}
Current output
error[E0277]: `Union` doesn't implement `Debug`
--> src/main.rs:13:5
|
13 | assert_eq!(Union { member: 0, }, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Union` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `Union`
= note: add `#[derive(Debug)]` to `Union` or manually `impl Debug for Union`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Union` with `#[derive(Debug)]`
|
2 + #[derive(Debug)]
3 | union Union {
|
For more information about this error, try `rustc --explain E0277`.
Desired output
error[E0277]: `Union` doesn't implement `Debug`
--> src/main.rs:13:5
|
13 | assert_eq!(Union { member: 0, }, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Union` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `Union`
= note: add manual `impl Debug for Union`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
Rationale and extra context
The help in the error should be removed when the type is a union, because if you follow that instruction, you will just run into the "this trait cannot be derived for unions" error.
Other cases
Rust Version
I tested it with stable in playground.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=baa42bb5a36216b734f9eb665173a70b
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
The help in the error should be removed when the type is a union, because if you follow that instruction, you will just run into the "this trait cannot be derived for unions" error.
Other cases
Rust Version
Anything else?
No response