Skip to content

Conversation

@camelid
Copy link
Member

@camelid camelid commented Jan 2, 2026

This PR:

  • Add support for linking to fields of variants behind a type alias.
  • Correctly resolve links to fields and variants behind a type alias to the alias's version of the docs.
  • Refactor some intra-doc links code to make it simpler.
  • Add tests for the status quo of linking to associated items behind aliases.

Future steps:

  • Nail down the rules of when inherent and trait impls are inlined into an alias's docs, and when impls on the alias appear for the aliased type.
  • Adjust the resolutions of intra-doc links, through aliases, to associated items based on these rules.

r? @GuillaumeGomez

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Jan 2, 2026
@GuillaumeGomez
Copy link
Member

Is it ready for review? (It's a draft so wondering ^^')

@camelid
Copy link
Member Author

camelid commented Jan 2, 2026

I'm planning to add one more commit, but it's mostly done.

@camelid
Copy link
Member Author

camelid commented Jan 2, 2026

It's best reviewed commit-by-commit btw since I moved a lot of code around.

@bors
Copy link
Collaborator

bors commented Jan 7, 2026

☔ The latest upstream changes (presumably #150645) made this pull request unmergeable. Please resolve the merge conflicts.

1 similar comment
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 7, 2026

☔ The latest upstream changes (presumably #150645) made this pull request unmergeable. Please resolve the merge conflicts.

Previously, these failed to resolve, despite them working for struct
fields or enum variants that were behind aliases.

However, there is now an inconsistency where enum variant fields behind
an alias resolve to the entry on the alias's page, while enum variants
and struct fields resolve to the page of the backing ADT.
The old name and API were confusing. In my opinion, looking up the type
at the call site is clearer.
All the other parts of this function return the Res for the containing
page, but for some reason, this returns the associated item itself. It
doesn't seem to affect the behavior of rustdoc because e.g. the href
functions use the parent if the DefId is for an assoc item. But it's
clearer and simpler to be consistent.
@camelid camelid force-pushed the intra-doc-assoc-alias branch 2 times, most recently from 2bd0b56 to 844ae64 Compare January 8, 2026 21:12
@camelid camelid marked this pull request as ready for review January 8, 2026 21:12
@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 Jan 8, 2026
@camelid
Copy link
Member Author

camelid commented Jan 8, 2026

Ok, I think this is ready for review now. It doesn't fix all the inconsistencies with type aliases and associated items, but it does improve the status quo and adds some tests so we'll notice if/when we change things.

The rules around when impls from an aliased type are inlined into the alias's docs seem pretty arbitrary and inconsistent, so we should probably nail that down before we adjust where intra-doc links go.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the intra-doc-assoc-alias branch from 844ae64 to 2b618ed Compare January 8, 2026 21:42
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.

5 participants