Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc::formats::Cache does not contain enough data to unwrap type aliases #138617

Open
lolbinarycat opened this issue Mar 17, 2025 · 2 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

lolbinarycat commented Mar 17, 2025

rustdoc has a lot of issues handling type aliases, and I think a large part of that is due to the fact that once the cleaned ast is constructed, type aliases are essentially opaque, and code cannot see what type they point to.

clean::TypeAlias does exist, but there's no way to get that from a Path item, which is what shows up in type args.

I encountered this when working on #138574

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 17, 2025
@lolbinarycat lolbinarycat added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 17, 2025
@lolbinarycat
Copy link
Contributor Author

@lolbinarycat
Copy link
Contributor Author

lolbinarycat commented Mar 22, 2025

I see 3 main ways this could be implemented:

  1. hold onto the TyCtxt for type alias resolution (kinda breaks the current model of rustdoc where rendering only depends on the cleaned AST)
  2. collect a map of all type aliases by hooking rustdoc::clean::inline::build_type_alias (simple, but may have significant memory overhead)
  3. collect a map of only the type aliases that are needed for rendering (eg. only type aliases that appear in the generic parameters of a deref Target type) (less memory usage, but significantly more complicated, and likely uses more cpu cycles)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants