We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
discr
Display
1 parent de13718 commit 20a134fCopy full SHA for 20a134f
src/librustdoc/html/render/print_item.rs
@@ -1656,11 +1656,9 @@ fn display_c_like_variant(
1656
} else if should_show_enum_discriminant {
1657
let adt_def = cx.tcx().adt_def(enum_def_id);
1658
let discr = adt_def.discriminant_for_variant(cx.tcx(), index);
1659
- if discr.ty.is_signed() {
1660
- write!(w, "{} = {}", name.as_str(), discr.val as i128)?;
1661
- } else {
1662
- write!(w, "{} = {}", name.as_str(), discr.val)?;
1663
- }
+ // Use `discr`'s `Display` impl to render the value with the correct
+ // signedness, including proper sign-extension for signed types.
+ write!(w, "{} = {}", name.as_str(), discr)?;
1664
} else {
1665
write!(w, "{name}")?;
1666
}
0 commit comments