# Rustdoc: resolve actual types in item definitions?

**URL:** <https://internals.rust-lang.org/t/rustdoc-resolve-actual-types-in-item-definitions/22626>\
**Category:** tools and infrastructure\
**Created:** [March 22, 2025, 3:40pm UTC](https://internals.rust-lang.org/t/rustdoc-resolve-actual-types-in-item-definitions/22626 "2025-03-22T15:40:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PonasKovas](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ponaskovas/32/13081_2.png) [@PonasKovas](https://internals.rust-lang.org/u/PonasKovas)\
**Post date:** [March 22, 2025, 3:40pm UTC](https://internals.rust-lang.org/t/rustdoc-resolve-actual-types-in-item-definitions/22626/1 "2025-03-22T15:40:36Z")

</div>

Hello, I'm generating some structs using macros and I specify the types of the fields using an associated type of another type, which is very convenient for me because of how my stuff is structured.

For example:

```rust
pub struct EncryptionBeginV766 {
    pub server_id: <String as MCP>::Data,
    pub public_key: <Buffer as MCP>::Data,
    pub verify_token: <Buffer as MCP>::Data,
    pub should_authenticate: <bool as MCP>::Data,
}

```

Here, the trait `MCP` is **private** and some of the types that implement it and are used here are **private** too, but the associated `MCP::Data` type is always **public**.

Unfortunately I found that `rustdoc` generates the docs for this struct like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/b/b1e18cf91ab61407d95401447398d481f6f3dc6c.png)

Obviously this is not very helpful to the user at all, since most of this stuff is private and they can't even see what it is, when in reality this resolves to some simple public type.

Could `rustdoc` resolve types specified like this to the actual canonical type paths instead? I personally don't really see a reason to not do it like this, unless it might be more informative (if the trait and used types were not private...) but for the user I think its way more convenient to just see the actual resolved type.

And if implementing this is possible, would it likely be hard and complicated or just a simple fix?

---

<div class="post-metadata">

**Author:** ![binarycat](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/binarycat/32/12210_2.png) [@binarycat](https://internals.rust-lang.org/u/binarycat)\
**Post date:** [March 22, 2025, 6:22pm UTC](https://internals.rust-lang.org/t/rustdoc-resolve-actual-types-in-item-definitions/22626/2 "2025-03-22T18:22:42Z")

</div>

I think this is yet another issue blocked by [rustdoc's inability to resolve type aliases at will](https://github.com/rust-lang/rust/issues/138617).

---

<div class="post-metadata">

**Author:** ![carloskiki](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/carloskiki/32/12774_2.png) [@carloskiki](https://internals.rust-lang.org/u/carloskiki)\
**Post date:** [December 4, 2025, 9:05pm UTC](https://internals.rust-lang.org/t/rustdoc-resolve-actual-types-in-item-definitions/22626/3 "2025-12-04T21:05:58Z")

</div>

I am also facing this exact issue...

For those looking for a fix, the flag `-Znormalize-docs` can be used. There is still a problem with macros however. The dependent package is responsible for using this flag, so macro libraries cannot enforce this on their dependents, they can only advocate them to use the flag.
