Derived traits in the standard library are missing stability information

c894d3a
Opened by jethrogb at 2022-01-18 22:16:13

impl Default for Duration was added in 1.15 but the current documentation doesn't indicate it wasn't available before that.

  1. We never talk about old versions for documentation; if you want to see that version's docs, check out the docs for that version.

    Thanks, but this is something we just don't do.

    Steve Klabnik at 2017-03-13 18:33:17

  2. I'm not sure what you mean, there are version numbers all over the page I linked.

    jethrogb at 2017-03-13 18:35:40

  3. I don't see "version" anywhere there, could you send me a screenshot or something? It's possible I'm just misunderstanding you.

    Steve Klabnik at 2017-03-13 18:39:50

  4. Ohhhh I see now, you're not talking about in text, you're talking about the stability flags.

    I believe that implementations are auto-stable, and therefore, don't have the flag, and therefore, don't have this. So this is more of a feature request.

    Sorry for the misunderstanding here.

    Steve Klabnik at 2017-03-13 18:40:50

  5. screen shot 2017-03-13 at 11 40 14-fullpage

    jethrogb at 2017-03-13 18:44:03

  6. The XyzAssign implementations have a version number though.

    jethrogb at 2017-03-13 18:45:49

  7. Likely because the trait itself was stabilized on that version number (trait XyzAssign was added in 1.9.0).

    Agreed that having a marker on impls would be useful.

    Cody Schafer at 2017-03-13 19:08:11

  8. Ok, looking at the source, it seems the cause is that you can't specify a stability attribute for a #[derive]. Related #29152

    jethrogb at 2017-03-13 19:13:14

  9. Triage: no changes I'm aware of.

    Steve Klabnik at 2018-09-24 16:12:47

  10. I don't think this is really a rustdoc bug - the information just isn't available in the source code. I'm not sure who's in charge of #[stable] and #[unstable], maybe T-compiler?

    That said, I think a syntax like #[derive(Clone(stable = "1.15.0"))] might be nice.

    jyn at 2020-12-16 02:04:28

  11. the information just isn't available in the source code

    It should be available, starting from https://github.com/rust-lang/rust/pull/29152 stability attributes are copied from the item to derived impls. If they are not displayed in the doc, then something goes wrong along the way.

    Vadim Petrochenkov at 2020-12-16 07:39:12

  12. https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=9ef33271d10b380c800731eb31835323

    #[stable(feature = "name", since = "version")]
    #[derive(Clone)]
    struct S;
    
    #[stable(feature = "name", since = "version")]
    struct S;
    #[automatically_derived]
    #[allow(unused_qualifications)]
    #[stable(feature = "name", since = "version")]
    impl ::core::clone::Clone for S {
        #[inline]
        fn clone(&self) -> S { match *self { S => S, } }
    }
    

    Vadim Petrochenkov at 2020-12-16 07:45:04

  13. Hmm, that seems like the wrong behavior though? Duration was stabilized in 1.3.0 but impl Default for Duration is only present since 1.15.0. I would rather not show the stability than show the wrong stability.

    jyn at 2020-12-16 13:21:47

  14. Ah, I see what is the issue now, the reported stabilization version for the impl is incorrect exactly because it's inherited from the item.

    I don't think it's something important enough to extend derive syntax for (or do anything else really).

    Vadim Petrochenkov at 2020-12-16 18:53:21