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 ignores inherent impls made in non-module scope #53763

Open
QuietMisdreavus opened this issue Aug 28, 2018 · 2 comments
Open

rustdoc ignores inherent impls made in non-module scope #53763

QuietMisdreavus opened this issue Aug 28, 2018 · 2 comments
Labels
C-bug Category: This is a bug. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@QuietMisdreavus
Copy link
Member

Similar to #52545, rustdoc doesn't see anything if it's not written into a module's scope. However, there are some things that can be written in function/expression scope that still make it out into the public API. While that issue was about trait impls, it seems that inherent impls work in a similar way. Consider the following snippet:

fn asdf() {
    impl SomeStruct {
        pub fn qwop(&self) {
            println!("hidden function");
        }
    }
}

fn main() {
    let asdf = SomeStruct;
    asdf.qwop(); // prints "hidden function"
}

Even though qwop() was written in function scope, it's still visible globally because it was defined with pub. Rustdoc should collect these impls and display them.

One thing i'm curious about is whether we should show non-pub functions defined in non-module scope when --document-private-items is set. I think we can get away with it, because it already displays private functions there regardless of where they're defined.

@QuietMisdreavus QuietMisdreavus added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 28, 2018
@QuietMisdreavus QuietMisdreavus self-assigned this Aug 28, 2018
@jyn514
Copy link
Member

jyn514 commented Aug 25, 2020

I think this might be fixed since #73566 ? Needs a test though.

@jyn514 jyn514 added the C-bug Category: This is a bug. label Aug 25, 2020
@jyn514 jyn514 assigned jyn514 and unassigned QuietMisdreavus Sep 9, 2020
@jyn514 jyn514 removed their assignment Aug 5, 2021
@jyn514
Copy link
Member

jyn514 commented Aug 5, 2021

Nope, this is still broken.
image

@jyn514 jyn514 added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. 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