Rustdoc impl blocks refer to private names

f2e2e98
Opened by David Tolnay at 2021-12-15 02:39:58

The flate2 crate is structured roughly like this:

mod gz {
    pub struct EncoderReader;

    impl EncoderReader {
        pub fn new() -> EncoderReader {
            unimplemented!()
        }
    }
}

pub use gz::EncoderReader as GzEncoder;

The rustdoc of GzEncoder is correctly titled but the impl blocks on the page refer to the private name of the type. I would expect the impl blocks and methods to use the public name, just like the top of the page does.


selection_030

  1. This bug affects reqwest as well. There is a type called reqwest::UrlError which is re-exported from url::ParseError so all of the rustdoc refers to the wrong name ParseError.

    David Tolnay at 2017-05-29 17:05:21

  2. I believe this bug is fixed now. Let me know if this issue can be closed, or close it yourself. Thanks.

    Noah Lev at 2021-12-15 00:04:00

  3. This is not fixed as of current nightly. cargo doc of the same code from above:

    Screenshot from 2021-12-14 16-37-39

    David Tolnay at 2021-12-15 00:38:08

  4. Hmm, I went to the latest version of the docs.rs page in the OP, but couldn't find GzEncoder in the crate root: https://docs.rs/flate2/1.0.22/flate2/index.html?search=gzencoder

    Noah Lev at 2021-12-15 00:39:09

  5. Also, oops: I didn't mean to close this issue! Thanks for re-opening it.

    Noah Lev at 2021-12-15 00:40:19

  6. I just ran cargo doc locally, and I'm still not seeing GzEncoder in the crate root, either via searching or the listing on the crate root's page. Where do you see GzEncoder?

    Noah Lev at 2021-12-15 00:44:58

  7. $ cat Cargo.toml 
    [package]
    name = "flate2"
    version = "0.0.0"
    edition = "2021"
    
    $ cat src/lib.rs 
    mod gz {
        pub struct EncoderReader;
    
        impl EncoderReader {
            pub fn new() -> EncoderReader {
                unimplemented!()
            }
        }
    }
    
    pub use gz::EncoderReader as GzEncoder;
    
    $ cargo doc --open
        Finished dev [unoptimized + debuginfo] target(s) in 0.00s
         Opening target/doc/flate2/index.html
    

    Screenshot from 2021-12-14 16-47-37

    David Tolnay at 2021-12-15 00:47:51

  8. Ah, I thought your screenshot was from the crate itself.

    Noah Lev at 2021-12-15 01:03:40

  9. Assigning myself for now to look into this.

    Noah Lev at 2021-12-15 02:39:58