Description
I am trying to upgrade my company's toolchain from 1.64 to 1.71. I noticed that we had some odd code that was compiling before and is no longer compiling. I got it down to a change between 1.64 and 1.65, and my first thought is that this might be affected by this PR: #98655
Notably that PR mentions that...
Observable behaviour may change if a user has defined a type A with an
inconsistent PartialEq and then defines a type B that contains an
A and also derives PartialEq. Such code is already buggy and
preserving bug-for-bug compatibility isn't necessary.
But I would imagine neither bool nor f32 would have an inconsistent PartialEq? I apologize if this is something that already is covered by that statement and I'm misunderstanding.
Such code is already buggy and
preserving bug-for-bug compatibility isn't necessary.
It does seem like my code is already buggy, but wanted to file this anyways in case someone else comes across it.
So this compiles on 1.64, and doesn't on 1.65.
#[derive(PartialEq, Eq)]
struct WithBool {
pub a: Option<bool>,
pub b: Option<f32>,
}
Notably, none of the following compiles on 1.64.
#[derive(Debug, PartialEq, Eq)]
struct WithoutBool {
pub b: Option<f32>,
}
#[derive(Debug, PartialEq, Eq)]
struct WithBoolNoOption {
pub a: bool,
pub b: Option<f32>,
}
#[derive(Debug, PartialEq, Eq)]
struct WithBoolNoOptionF32 {
pub a: Option<bool>,
pub b: f32,
}
Code
I tried this code:
#[derive(PartialEq, Eq)]
struct WithBool {
pub a: Option<bool>,
pub b: Option<f32>,
}
I expected to see this happen: It would compile on both or not compile on both.
Instead, this happened: It only compiles on 1.64 (which surprised me given I didn't think f32 impl'd Eq).
Version it worked on
This compiled on Rust 1.64, but did not compile on Rust 1.65.
It most recently worked on: Rust 1.64
Version with regression
rustc --version --verbose
:
brendondaugherty@C6W2M6LRF4 f32_not_eq % rustc --version --verbose
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0
Backtrace
The compiler did not crash.
Backtrace
<backtrace>