about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-03 18:48:30 +0000
committerbors <bors@rust-lang.org>2024-08-03 18:48:30 +0000
commitbbf60c897e18a72923129c63ff33ce2de2968815 (patch)
tree0696b8dd5e144ba7f3e70d5f732a2170891d08f3 /compiler/rustc_pattern_analysis/src
parentedc4dc337b28a389dbd87b3825d7929381edeb8f (diff)
parent1f9d9603c05a1fb56825b4fc54ea28aa04485024 (diff)
downloadrust-bbf60c897e18a72923129c63ff33ce2de2968815.tar.gz
rust-bbf60c897e18a72923129c63ff33ce2de2968815.zip
Auto merge of #127324 - DianQK:match-br, r=cjgillot
Simplify match based on the cast result of `IntToInt`

Continue to complete #124150. The condition in #120614 is wrong, e.g. `-1i8` cannot be converted to `255i16`. I've rethought the issue and simplified the conditional judgment for a more straightforward approach. The new approach is to check **if the case value after the `IntToInt` conversion equals the target value**.

In different types, `IntToInt` uses different casting methods. This rule is as follows:

- `i8`/`u8` to `i8`/`u8`: do nothing.
- `i8` to `i16`/`u16`: sign extension.
- `u8` to `i16`/`u16`: zero extension.
- `i16`/`u16` to `i8`/`u8`: truncate to the target size.

The previous error was a mix of zext and sext.

r? mir-opt
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions