Skip to content

rustdoc is confusing for use Foo as Bar types #111886

@nathan-at-least

Description

@nathan-at-least

While examining API docs for ipfs_api_backend_hyper::IpfsClient I was confused about the relationship between the symbol IpfsClient and HyperBackend:

Screenshot 2023-05-23 11 09 19

I knew that rustdoc explicitly annotates type aliases, but that wasn't what I was seeing, so I fetched the code to examine and find a statement similar to use my_path::HyperBackend as IpfsClient. Ok, but could rustdoc have helped me know this was happening?

I expected to see this happen:

I hope to see some explicit indication that the two symbols refer to the same item. The actual approach might be tricky to get right in a manner that is explicit but not too much clutter.

I've seen rustdoc explicitly annotate that when re-exporting across crate boundaries. Is there some way to do this for intra-crate renaming re-exports so that the crate-level doc would move IpfsClient out of the structs section and into a re-exports section with a crate-local path? It currently looks like this:

image

With this proposed approach, the rendering for the type interface would consistently use HyperBackend.

Related Tickets

I searched this issue tracker with is:issue is:open use as label:A-rustdoc-ui to find these tickets both of which rename to _ which is distinct from my issue:

I filed this PR against rust-ipfs-api which replaces use foo as bar with explicit type aliases as a work-around. That PR has more screenshots of the difference in doc rendering between the two approaches.

Meta

rustc --version --verbose:

Whatever https://docs.rs used to render https://docs.rs/ipfs-api-backend-hyper/0.6.0/ipfs_api_backend_hyper/index.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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