Skip to content

Add cargo fix support for switching to intra-doc links #75805

@jyn514

Description

@jyn514

This will be tricky for several reasons.

  • It needs pulldown support to look at the links even if they're not broken. Event and Tag seem like they should work.
  • Rustdoc needs to know what the link is meant to resolve to. This can be tricky if the item is re-exported in multiple places (see e.g. Broken links in String documentation from Deref impl #32129). Rustdoc should report all possible items you meant if there's ambiguity (and downgrade the applicability).
  • Rustdoc needs to know what name in scope matches with the item you're linking too. This seems like it shouldn't be too hard, but I don't see a way to go from DefId -> Path on Resolver, only the reverse. cc @Manishearth, do you have ideas?

This can be implemented as an allowed-by-default lint with Applicability::MachineApplicable; then cargo fix will pick it up automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions