|
| 1 | +#![feature(rustc_attrs)] |
| 2 | +#![crate_type = "lib"] |
| 3 | +//@ edition: 2024 |
| 4 | + |
| 5 | +// Edge-case tests for the conversion from `rustc_abi::WrappingRange` to |
| 6 | +// LLVM range attributes. |
| 7 | + |
| 8 | +#[rustc_layout_scalar_valid_range_start(1)] |
| 9 | +pub struct LowNiche8(u8); |
| 10 | +// CHECK: define void @low_niche_8(i8 noundef range(i8 1, 0) %_1) |
| 11 | +#[unsafe(no_mangle)] |
| 12 | +pub fn low_niche_8(_: LowNiche8) {} |
| 13 | + |
| 14 | +#[rustc_layout_scalar_valid_range_end(254)] |
| 15 | +pub struct HighNiche8(u8); |
| 16 | +// CHECK: define void @high_niche_8(i8 noundef range(i8 0, -1) %_1) |
| 17 | +#[unsafe(no_mangle)] |
| 18 | +pub fn high_niche_8(_: HighNiche8) {} |
| 19 | + |
| 20 | +#[rustc_layout_scalar_valid_range_start(1)] |
| 21 | +#[rustc_layout_scalar_valid_range_end(254)] |
| 22 | +pub struct Niches8(u8); |
| 23 | +// CHECK: define void @niches_8(i8 noundef range(i8 1, -1) %_1) |
| 24 | +#[unsafe(no_mangle)] |
| 25 | +pub fn niches_8(_: Niches8) {} |
| 26 | + |
| 27 | +#[rustc_layout_scalar_valid_range_start(255)] |
| 28 | +#[rustc_layout_scalar_valid_range_end(255)] |
| 29 | +pub struct SoloHigh8(u8); |
| 30 | +// CHECK: define void @solo_high_8(i8 noundef range(i8 -1, 0) %_1) |
| 31 | +#[unsafe(no_mangle)] |
| 32 | +pub fn solo_high_8(_: SoloHigh8) {} |
| 33 | + |
| 34 | +#[rustc_layout_scalar_valid_range_start(1)] |
| 35 | +#[rustc_layout_scalar_valid_range_end(340282366920938463463374607431768211454)] // (u128::MAX - 1) |
| 36 | +pub struct Niches128(u128); |
| 37 | +// CHECK: define void @niches_128(i128 noundef range(i128 1, -1) %_1) |
| 38 | +#[unsafe(no_mangle)] |
| 39 | +pub fn niches_128(_: Niches128) {} |
0 commit comments