Skip to content

fix: parse doc link with turbofish generics - #23334

Open
dimxy wants to merge 1 commit into
rust-lang:masterfrom
dimxy:fix-doc-link-parse
Open

fix: parse doc link with turbofish generics#23334
dimxy wants to merge 1 commit into
rust-lang:masterfrom
dimxy:fix-doc-link-parse

Conversation

@dimxy

@dimxy dimxy commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This PR refactors doc_modpath_from_str fn marked with "FIXME" and fixes parsing of links with turbofish.

There are a few issues with the existing function:

  • it is implemented as ad-hoc code although the syntax crate contains ready-to-use features to parse type paths.
  • adding tuple index to mod path (which is invalid there) looks odd.
  • there is a bug: paths with turbofish generics are parsed incorrectly. For example, "S::<i32>::f" is parsed as
    ModPath { kind: Plain, segments: [Name { symbol: "S", ctx: () }, Name { symbol: "", ctx: () }, Name { symbol: "f", ctx: () }] } (extra empty "symbol" in the middle) and cannot be navigated in r-a GUI.

The proposed solution:

  • adds impl ast::Type { fn parse(..) } similar to existing ast::Expr.
  • implements a new mod_path_from_doc_link fn with uses new ast::Type::parse and existing ModPath::from_src.
  • handles tuple file index separately from the modpath, in the caller function.
  • correctly parses turbofish generics (now trackable in r-a GUI).

Disclaimer: Claude Code was used to help with code analysis, reviewing changes and suggesting tests.

Refactor doc link mod path parsing code.
@dimxy
dimxy marked this pull request as ready for review September 9, 2026 17:28
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 9, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants