diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 3c96f8736814e..49967c9e32b2f 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1540,7 +1540,8 @@ fn display_c_like_variant(
) {
let name = item.name.unwrap();
if let Some(ref value) = variant.discriminant {
- write!(w, "{} = {}", name.as_str(), value.value(cx.tcx(), true));
+ let v = value.expr(cx.tcx()).unwrap_or(value.value(cx.tcx(), true));
+ write!(w, "{} = {}", name.as_str(), v);
} else if should_show_enum_discriminant {
let adt_def = cx.tcx().adt_def(enum_def_id);
let discr = adt_def.discriminant_for_variant(cx.tcx(), index);
diff --git a/tests/rustdoc/src-discrim.perms.html b/tests/rustdoc/src-discrim.perms.html
new file mode 100644
index 0000000000000..ac7c722f97eac
--- /dev/null
+++ b/tests/rustdoc/src-discrim.perms.html
@@ -0,0 +1,6 @@
+#[repr(u8)]
pub enum Permissions {
+ Guest = b'%',
+ User = b'$',
+ System = b'@',
+ Absolute = b'#',
+}
\ No newline at end of file
diff --git a/tests/rustdoc/src-discrim.rs b/tests/rustdoc/src-discrim.rs
new file mode 100644
index 0000000000000..347a233f44427
--- /dev/null
+++ b/tests/rustdoc/src-discrim.rs
@@ -0,0 +1,12 @@
+//! regression test for #128347
+#![crate_name = "foo"]
+
+//@ snapshot perms foo/enum.Permissions.html '//pre/code'
+
+#[repr(u8)]
+pub enum Permissions {
+ Guest = b'%',
+ User = b'$',
+ System = b'@',
+ Absolute = b'#',
+}