rustdoc prints the names of private consts when used as const generic parameter defaults
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
const VALUE: usize = 1;
type Ty = ();
pub trait Foo<const N: usize = VALUE, T = Ty> {}
Rustdoc generates the following pseudocode for this trait’s documentation page:
pub trait Foo<const N: usize = VALUE, T = ()> { }
This seems inconsistent to me: non-public constants should be replaced with their value just like non-public type aliases are, because crates should be free to have aliases for their own things privately without affecting the public view.
Another case is when a public constant uses a private constant; in that case, the private constant is named and the final value is. I’m not sure whether that’s good, but it at least answers the question of what the value is.
Meta
rustc --version --verbose:
rustc 1.82.0-nightly (41dd149fd 2024-08-11)
binary: rustc
commit-hash: 41dd149fd6a6a06795fc6b9f54cb49af2f61775f
commit-date: 2024-08-11
host: x86_64-apple-darwin
release: 1.82.0-nightly
LLVM version: 19.1.0
@rustbot label +T-rustdoc
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Rust snippet in the issue and run rustdoc to reproduce the generated trait documentation. Trace the rustdoc entry point that renders const generic defaults; done means private constants are represented by their values rather than private names, with the public-constant case covered as well.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100