Closed LilyIsTrans closed 3 months ago
(cargo expand
output on the example given above)
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
pub struct Magnitude<const BYTES : usize>([u8; 0]);
impl ::core::cmp::PartialEq for Magnitude {
#[inline]
#[must_use]
fn eq(&self, other: &Self) -> bool {
::bytemuck::bytes_of(self) == ::bytemuck::bytes_of(other)
}
}
impl ::core::cmp::Eq for Magnitude {}
This isn't a compiler bug, the ByteEq
derive macro doesn't currently emit generics on the PartialEq and Eq impls (which it probably should, or should emit an error that it doesn't support generics).
Opened a PR to allow deriving ByteEq
and ByteHash
for types with generics.
Note that ByteEq
and ByteHash
require the type implement NoUninit
, which cannot currently be derived for generic structs, and must be manually verified to be correct and implemented.
Right off the bat, here's the minimum reproducible example: Cargo.toml:
The bug still occurs identically if swapping out
bytemuck::ByteEq
forbytemuck::ByteHash
.The error from
cargo check
is:Following it's inane suggestion, unsurprisingly, does not fix the issue.
I got this from the rather more reasonable code:
Which gives an identical error message other than that it shows the longer source code.
Considering how inane the suggestion from rustc is, I suspect this may actually be a compiler bug, but I want to get a second opinion before I go opening an issue claiming a compiler error, especially for code involving macros I didn't write.