Skip to content

rustdoc shows duplicate bounds for derived implementations #25022

@solson

Description

@solson
Member

See the derived implementations at the bottom of http://doc.rust-lang.org/1.0.0-beta.3/std/num/struct.Wrapping.html for example.

impl<T> Clone for Wrapping<T> where T: Clone + Clone

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on May 1, 2015
solson

solson commented on May 6, 2015

@solson
MemberAuthor

Interestingly, impl<Idx> Clone for Range<Idx> where Idx: Clone + Clone + Clone has Clone three times. My theory is that there's an extra bound for each use of the type parameter inside the struct, since Wrapping<T> has one T field and Range<Idx> has two Idx fields.

tomjakubowski

tomjakubowski commented on Jun 5, 2015

@tomjakubowski
Contributor

I think this is a bug in #[derive(Clone)], actually.

// bar.rs
#[derive(Clone)]
struct Foo<T>(pub T);

fn main() {
}

The results of --pretty=expanded:

#![feature(no_std)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
struct Foo<T>(pub T);
#[automatically_derived]
impl <T: ::std::clone::Clone> ::std::clone::Clone for Foo<T> where
 T: ::std::clone::Clone {
    #[inline]
    fn clone(&self) -> Foo<T> {
        match *self {
            Foo(ref __self_0_0) =>
            Foo(::std::clone::Clone::clone(&(*__self_0_0))),
        }
    }
}

fn main() { }

Note the extra bound on T. The only weird thing rustdoc is doing is writing that as a where clause, which I'd expect because that's all it can do for bounds on an inlined doc item such as std::num::Wrapping (for now).

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

    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

        Participants

        @solson@alexcrichton@tomjakubowski

        Issue actions

          rustdoc shows duplicate bounds for derived implementations · Issue #25022 · rust-lang/rust