Skip to content

Trait bounds of methods from Deref impls are not rendered #84630

Open

Description

In #80653 methods from Deref targets were added to rustdoc output. However, it seems that trait bounds on these methods are not rendered.

I tried this code:

use std::ops::Deref;

pub trait Foo {}

pub struct Bar<T>(T);

impl<T> Bar<T> {
    pub fn generic(&self) {}
}

impl<T> Bar<T>
where
    T: Foo,
{
    pub fn with_foo(&self) {}
}

pub struct Baz(Bar<()>);

impl Deref for Baz {
    type Target = Bar<()>;

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

pub struct Qux<T>(Bar<T>);

impl<T> Deref for Qux<T> {
    type Target = Bar<T>;

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

I expected to see this happen:

The relevant methods added by the Deref impls on Baz and Qux are added to the output of rustdoc. For Baz this is generic, and for Qux this is generic and with_foo (including the trait bound).

Instead, this happened:

Both methods are visible in the documentation of Baz and Qux without a trait bound T: Foo on the with_foo method.

Screenshot 2021-04-27 at 22 47 10

Screenshot 2021-04-27 at 22 46 39

Screenshot 2021-04-27 at 22 47 39

Meta

Tested with stable and nightly.

cargo rustc -- --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-apple-darwin
release: 1.51.0
LLVM version: 11.0.1

cargo +nightly rustc -- --version --verbose:

rustc 1.53.0-nightly (42816d61e 2021-04-24)
binary: rustc
commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
commit-date: 2021-04-24
host: x86_64-apple-darwin
release: 1.53.0-nightly
LLVM version: 12.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-traitsArea: Trait systemC-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