-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical priorityregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
$ cat a.rs
#[derive(Debug, Eq, PartialEq)]
pub enum Type {
A = 1,
B = 2,
}
pub fn encode(v: Type) -> Type {
match v {
Type::A => Type::B,
_ => v,
}
}
fn main() {
assert_eq!(Type::B, encode(Type::A));
}
$ rustc -Zmir-opt-level=0 a.rs && ./a
$ rustc a.rs && ./a
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `B`,
right: `A`', a.rs:13:3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Originally found by @bonega when experimenting with discriminants starting from 1 in #88984 (comment).
@rustbot modify labels: +regression-from-stable-to-stable +I-unsound
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical priorityregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.