Skip to content

rustdoc: Methods from deref is missing methods #160236

Description

@camelid

Methods from deref is only showing the associated constants, but not the methods, for https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/struct.AbiAlign.html.

AbiAlign:
Image

Align (the deref target):

Image

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jul 30, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 30, 2026
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 30, 2026
  4. camelid commented on Jul 30, 2026

    @camelid
    MemberAuthor
  5. camelid commented on Jul 30, 2026

    @camelid
    MemberAuthor

    This doesn't appear to be a (recent) regression, since the same issue occurs on 1.97.1 stable https://doc.rust-lang.org/stable/nightly-rustc/rustc_abi/struct.AbiAlign.html.

  6. GuillaumeGomez commented on Jul 31, 2026

    @GuillaumeGomez
    Member

    Gonna take a look in the next days.

  7. GuillaumeGomez commented on Aug 10, 2026

    @GuillaumeGomez
    Member

    So, associated functions (without self) cannot be called through Deref, so seems normaly that they're not listed. As for methods with &self, they work as expected. However for self methods, it's more tricky as they cannot be called from Deref unless the type is Copy. So I'll take into account if the Derefed type implements Copy, and if so, lists self methods in this case.

  8. GuillaumeGomez commented on Aug 10, 2026

    @GuillaumeGomez
    Member

    However we shouldn't list associated consts either since they cannot be accessed either. Multiple weird things going on here.

    Code I used to test:

    #![feature(inherent_associated_types)] // Needed for `Y::TWO`.
    
    pub struct X {
        y: Y,
    }
    
    impl std::ops::Deref for X {
        type Target = Y;
    
        fn deref(&self) -> &Self::Target {
            &self.y
        }
    }
    
    #[derive(Clone, Copy)]
    pub struct Y;
    
    impl Y {
        pub const ONE: X = X { y: Y };
        pub type TWO = u32;
    
        pub fn foo() {}
        pub fn bar(&self) {}
        pub fn babar(self) {}
    }
    
    fn main() {
        let x = Y::ONE;
    
        x.bar();
        x.babar(); // Since `Y` is `Copy`, it compiles.
    
        // `X` doesn't have a `ONE` associated const, so fails to compile.
        // let y = X::ONE;
        // `X` doesn't have a `TWO` associated type, so fails to compile.
        // let y: X::TWO = 0;
    }

    Now let's write the fix.

  9. camelid commented on Aug 10, 2026

    @camelid
    MemberAuthor

    Yeah, it seems like the whole analysis is just busted right now.

  10. added 3 commits that reference this issue on Oct 5, 2026
    ddddcbb
    6a3bb96
    3c67d2d
  11. added a commit that references this issue on Oct 6, 2026
    9d02933
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

    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