Skip to content

rustdoc: Show use-site paths for unevaluated const array lengths#158334

Open
lapla-cogito wants to merge 1 commit into
rust-lang:mainfrom
lapla-cogito:rustdoc_typeconst
Open

rustdoc: Show use-site paths for unevaluated const array lengths#158334
lapla-cogito wants to merge 1 commit into
rust-lang:mainfrom
lapla-cogito:rustdoc_typeconst

Conversation

@lapla-cogito

@lapla-cogito lapla-cogito commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

After #158171, I noticed a few additional issues with the rendering of consts in rustdoc. This PR fixes them. When rendering array lengths, avoid inlining the full definition of unevaluated constants via print_inlined_const. Instead, fall back to Const::to_string() for use-site rendering, matching the behavior already used for projections without bodies.

r? camelid

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 23, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@camelid camelid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one comment.

View changes since this review

Comment thread src/librustdoc/clean/utils.rs Outdated
inline::print_inlined_const(tcx, def_id)
}
ty::ConstKind::Alias(_, ty::AliasConst { kind, .. }) => {
let def_id = kind.opt_def_id().unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is weird since it returns Option but is always Some currently... not sure what's up with that. Could you change this to match exhaustively on the kind to extract the DefId, so that we don't end up with ICEs in the function is changed? No need to change the code below, just this let.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 29, 2026
@lapla-cogito

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants