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

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

Open
mbrobbel opened this issue Apr 27, 2021 · 0 comments
Open

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

mbrobbel opened this issue Apr 27, 2021 · 0 comments
Labels
A-traits Area: Trait system C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@mbrobbel
Copy link

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
@mbrobbel mbrobbel added the C-bug Category: This is a bug. label Apr 27, 2021
@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-traits Area: Trait system and removed T-rustdoc labels Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. 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

3 participants