rust-lang / rust-lang/rust

`GenericArg::Infer` may be unreachable in `rustdoc-types`

Open
#140,679 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

GenericArg::Infer was introduced in #83484 as a part of #85077. AFAICT, as rustdoc-types are converted from HIR, this variant was propagated to rustdoc-types. It was even documented later in #127290. But is it possible to obtain?

GenericArg is a part of GenericArgs that is a part of AssocItemConstraint, Path, and Type::QualifiedPath. Attempts to use the _ placeholder for any of them fail with the same error E0121. I've also tried to get this variant by generating JSON docs of a few huge crates, but to no avail. I guess it's impossible to use the placeholder in any position inside any item's signature. The only place it's allowed is in statements/expressions that're not represented in rustdoc-types.

I think if there's no intention to allow the placeholder inside item signatures, this variant should be removed from rustdoc-types.

The same also may be applicable to Type::Infer, but I didn't checked it as it's not important for my use case.

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 tracing how HIR conversion produces rustdoc-types::GenericArg and Type::Infer, then inspect generated JSON documentation for signatures containing GenericArgs. Use the linked playground cases as reproduction attempts. Done means confirming whether these variants are reachable in item signatures and, if not, removing or updating the affected rustdoc-types API with appropriate validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.