Closed
Description
#![feature(const_fn, rustc_attrs, attr_literals, untagged_unions)]
/// A single unconstrained byte (0-255).
#[derive(Copy, Clone, Debug)]
pub struct ImmByte(u8);
impl ImmByte {
/// Constructor
#[inline]
#[rustc_args_required_const(0)]
pub const fn new(value: u8) -> Self {
ImmByte(value)
}
}
pub struct v128([u8; 16]);
impl v128 {
#[inline]
#[rustc_args_required_const(0)]
pub const unsafe fn const_(imm: [ImmByte; 16]) -> v128 {
union U {
imm: [ImmByte; 16],
vec: v128,
}
U { imm }.vec
}
}
fn main() {
let _a = v128::const_([
ImmByte::new(0),
ImmByte::new(1),
ImmByte::new(2),
ImmByte::new(3),
ImmByte::new(4),
ImmByte::new(5),
ImmByte::new(6),
ImmByte::new(7),
ImmByte::new(8),
ImmByte::new(9),
ImmByte::new(10),
ImmByte::new(11),
ImmByte::new(12),
ImmByte::new(13),
ImmByte::new(14),
ImmByte::new(15),
]);
}
produces
error: internal compiler error: librustc_mir/transform/promote_consts.rs:334: impossible case reached
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:578:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error
cc @oli-obk