rust-lang / rust-lang/rust

rustdoc: Consider adding CCI for the HIR expressions of public constants

Open
#132,443 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

When a constant is inlined into another crate, we are forced to always show the evaluated/folded version of the constant. This is because we don't have access to the original HIR in the metadata.

This could be a situation where we can use (https://github.com/rust-lang/rfcs/pull/3662) to store the original expression for public constants (that could potentially be inlined by other crates) so that we don't have the cross-crate issue. Might be applicable to other cross-crate inconsistencies too (though hopefully the type alias one will be resolved by lazy_type_alias).

Adapted from a post by @camelid in https://github.com/rust-lang/rust/issues/131975#issuecomment-2451225947

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading RFC pull request 3662 and the discussion in issue 131975, then trace how rustdoc obtains public constant information from cross-crate metadata. Determine the intended treatment of original HIR expressions for inlined constants and define completion by resolving the documented cross-crate inconsistency without regressing other cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.