Skip to content

Incoming breakage in Rust 1.97.0 #145

Description

@theemathas

I'm from the Rust Programming Language team, and I found your repo via a crater run. I'm notifying you that your code will unfortunately stop working in the upcoming Rust 1.97.0 release.

In particular, your tests will start failing, as seen from this log (https://crater-reports.s3.amazonaws.com/beta-1.97-3-v2/1.97.0-beta.1/gh/0xflick.flichess/log.txt), which ran your test suite with the beta version of Rust (which will later become the stable 1.97.0 version). You can use the beta version to test your code now if you wish to reproduce the results locally.

The cause of the breakage is this code (although I do not know if there are other breakages currently masked by this one):

#[inline]
pub fn promotion(self) -> Option<Role> {
unsafe { std::mem::transmute((self.0 >> 12) as u8) }
}

Here, you are transmuting a u8 to an Option<Role>. Role is an enum which is represented as values from 0 to 5. Previously, Rust chose to represent an Option<Role> by using 6 to represent None, and your program relies on this particular value being chosen. However, in Rust 1.97.0, it will start using 255 to represent None, as that usually results in more efficient code. This change was made in rust-lang/rust#155473.

This change in layout does not constitute a break of Rust's stability promises, as Option does not have a guaranteed layout other than some particular documented cases. So, you should not rely on Option having any particular layout.

I apologize for your inconvenience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions