Rustdoc: generic implementation missing from implementors list


#1

If I create a trait such as this one, in a library:

use std::io::Read;

impl<T: ?Sized> Foo for T where T: Read {}

trait Foo: Read {
    fn foo(&mut self) -> String {
        ... some reading and parsing ...
    }
}

Running cargo doc, I would expect to see impl<T> Foo for T where T: Read in the list of implementors on the Foo trait documentation page. The header is there but that’s it, the list is empty.

The impl line does appear in a bin crate though, is this normal or is it a bug ?


#2

I’ve seen the same thing, just never investigated it.


#3

Blanket-implemented traits in rust itself have the same behavior:

Behavior changes for the reexported version std::string::ToString, there’s it’s correct.


#4

Ditto. I ended up adding a note to the conv::ConvUtil documentation about it:

Note: There appears to be a bug in rustdoc's output. This trait is implemented for all types, though the methods are only available for types where the appropriate conversions are defined.


#5

Reported issue #29503


#6

Indeed I thought I had seen it before in the std lib, but I couldn’t remember where. Thanks for your answers, I wanted to make sure before filling a BR but you did that already :slight_smile: