Skip to content

Rustdoc doesn't see trait implementations inside of functions #41480

Closed
@RReverser

Description

@RReverser

It's possible to define trait implementations inside of functions in Rust. This is useful not too often, but particularly nice if you have a macro that both defines trait implementation and calls some initialization for a given type.

Anyway, the following code is valid in Rust itself:

pub struct S;

pub fn a() {
    impl From<u8> for S {
        fn from(_: u8) -> S {
            S
        }
    }
}

But Rustdoc doesn't generate documentation for a given trait, despite it being visible to Rust itself, and being immediately available and unique across entire crate.

I can move impl out of the function and then it gets seen by Rustdoc, but this is rather inconvenient when impl is generated as part of a bigger macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.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