-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc_codegen_ssa: Fix for codegen_get_discr
When doing the optimized implementation of getting the discriminant, the arithmetic needs to be done in the tag type so wrapping behavior works correctly. Fixes #104519
- Loading branch information
Michael Benfield
committed
Nov 18, 2022
1 parent
fd3bfb3
commit 31c0645
Showing
3 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// run-pass | ||
#![allow(dead_code)] | ||
|
||
enum OpenResult { | ||
Ok(()), | ||
Err(()), | ||
TransportErr(TransportErr), | ||
} | ||
|
||
#[repr(i32)] | ||
enum TransportErr { | ||
UnknownMethod = -2, | ||
} | ||
|
||
#[inline(never)] | ||
fn some_match(result: OpenResult) -> u8 { | ||
match result { | ||
OpenResult::Ok(()) => 0, | ||
_ => 1, | ||
} | ||
} | ||
|
||
fn main() { | ||
let result = OpenResult::Ok(()); | ||
assert_eq!(some_match(result), 0); | ||
|
||
let result = OpenResult::Ok(()); | ||
match result { | ||
OpenResult::Ok(()) => (), | ||
_ => unreachable!("message a"), | ||
} | ||
match result { | ||
OpenResult::Ok(()) => (), | ||
_ => unreachable!("message b"), | ||
} | ||
} |