Skip to content

Methods from Deref<Target=[T]> doesnt appear for type aliases #134868

Description

@drewcassidy

I have a type alias for a type that implements Deref<Target=[T], but Rustdoc doesnt generate the corresponding section in the sidebar like it does for the concrete type I'm aliasing

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct Col<T: Copy, const N: usize> {
    data: [T; N],
}

pub type Mat<T, const H: usize, const W: usize> = Col<Col<T, W>, H>;

// snip

impl<T: Copy, const N: usize> Deref for Col<T, N> {
    type Target = [T];

    fn deref(&self) -> &Self::Target {
        &self.data
    }
}

rustdoc 1.82.0 (f6e511e 2024-10-15) on macOS 15.2

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 29, 2024
  2. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 29, 2024
  3. camelid commented on Dec 29, 2024

    @camelid
    Member

    This is because rustdoc injects impls for type aliases using JS (to avoid doc size ballooning). The Deref impl is shown, just not the specialized Methods from Deref section. I suppose we'd just need to add special support for this to the code that generates the JS, as well as to the JS itself? cc @notriddle

  4. added
    A-rustdoc-jsArea: Rustdoc's JS front-end
    T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
    on Dec 29, 2024
  5. notriddle commented on Dec 30, 2024

    @notriddle
    Contributor

    Yes, that sounds like a reasonable idea.

    The discussion I've been putting off is whether Deref should, in general, work this way. There's not really any particular difference from type aliases: most crates use it sparingly, but a few of them (for example, gtk) make extensive use of it.

  6. GuillaumeGomez commented on Sep 30, 2026

    @GuillaumeGomez
    Member

    Opened #163571.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsArea: Rustdoc's JS front-endC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions