Skip to content

Commit 7f76b8b

Browse files
Rollup merge of #155850 - scottmcm:tweak_niche_assignment, r=mati865
Only exclude the #155473 change for 1-byte bool-likes That's the thing we handle differently in codegen (see `to_immediate_scalar`) so if the other ones are fine, that helps narrow it down further. cc #155473
2 parents eac6db9 + 569ad99 commit 7f76b8b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

compiler/rustc_abi/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,8 @@ impl Niche {
20842084
let distance_end_zero = max_value - v.end;
20852085
// FIXME: this ought to work for `bool` too, but that seems to be hitting a miscompilation
20862086
// <https://github.com/rust-lang/rust/pull/155473#issuecomment-4302036343>
2087-
if count == 1 && v != (WrappingRange { start: 0, end: 1 }) {
2087+
let is_bool = size.bytes() == 1 && v == WrappingRange { start: 0, end: 1 };
2088+
if count == 1 && !is_bool {
20882089
// We only need one, so just pick the one closest to zero.
20892090
// Not only does that obviously use zero if it's possible, but it also
20902091
// simplifies testing things like `Option<char>`, since looking for `-1`

tests/codegen-llvm/function-arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub fn return_slice(x: &[u16]) -> &[u16] {
297297
x
298298
}
299299

300-
// CHECK: { i16, i16 } @enum_id_1(i16 noundef{{( range\(i16 0, 3\))?}} %x.0, i16 %x.1)
300+
// CHECK: { i16, i16 } @enum_id_1(i16 noundef{{( range\(i16 -1, 2\))?}} %x.0, i16 %x.1)
301301
#[no_mangle]
302302
pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> {
303303
x

0 commit comments

Comments
 (0)