Closed
Description
See #55701 (comment), this is just one-line addition for the assert.
Currently, this example:
#![feature(repr128)]
#[repr(u128)]
pub enum Foo {
Lo,
Hi = 1 << 64,
Bar = 18_446_745_000_000_000_123,
}
pub fn foo() -> Option<Foo> {
None
}
has this in its LLVM IR (in debug mode):
!22 = !DIDerivedType(tag: DW_TAG_member, name: "None", scope: !20, file: !6, baseType: !23, size: 128, align: 64, extraData: i64 926290448508)
Note the extraData
, which indicates the discriminant (niche, in this case), it should be the same value as Foo::Bar
, plus 1
, but is instead the truncated value (see below).
The debuginfo for Foo
is also wrong, but that is caused elsewhere in the codebase (in a spot where no assertion was ever added AFAIK. also see #59509 (comment)):
!10 = !DIEnumerator(name: "Lo", value: 0)
!11 = !DIEnumerator(name: "Hi", value: 0)
!12 = !DIEnumerator(name: "Bar", value: 926290448507)
The compiler should ICE, instead, to avoid generating the wrong debuginfo.
Alternatively, if LLVM and DWARF support it, we should encode the 128-bit discriminant, by employing const_uint_big
instead of const_u64
here:
Also, this field would need to become
Option<u128>
: