-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Consider the following code as lib.rs:
pub trait Foo {
type AssocType;
const THE_CONST: Self::AssocType;
}
pub struct Bar;
impl Foo for Bar {
type AssocType = u32;
const THE_CONST: Self::AssocType = 1;
}Running cargo doc and opening the generated html, one sees
Note
const THE_CONST: Self::AssocType = {transmute(0x00000001): <Bar as Foo>::AssocType}
Instead of the more reasonably expected
const THE_CONST: Self::AssocType = 1u32
or, barring that, just nothing instead of the confusing transmute string.
Meta
rustc --version --verbose:
rustc 1.91.0 (f8297e351 2025-10-28)
binary: rustc
commit-hash: f8297e351a40c1439a467bbbb6879088047f50b3
commit-date: 2025-10-28
host: x86_64-unknown-linux-gnu
release: 1.91.0
LLVM version: 21.1.2
See also
- Zulip chat
- Existing similar issue
- Manual bisection points to the issue being introduced in 1.62
Possible workaround
Explicitly setting the const's concrete type instead of using the trait's associated type
impl Foo for Bar {
type AssocType = u32;
const THE_CONST: u32 = 1;
}
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
