Uh oh!
There was an error while loading. Please reload this page.
Document default values for primitive types - #43252
Conversation
retep998
commented
Jul 15, 2017
Bikeshedding alternative phrasing: |
vbrandl
commented
Jul 16, 2017
Shouldn't @rust-highfive assign a reviewer to this PR? Or do I have to do it manually or just wait? |
GuillaumeGomez
left a comment
There was a problem hiding this comment.
A light rewording would be better I think.
| default_impl! { char, '\x00' } | ||
| default_impl! { (), (), "Returns the default value of `()`" } | ||
| default_impl! { bool, false, "Returns the default value of `false`" } | ||
| default_impl! { char, '\x00', "Returns the default value of `\\x00`" } |
There was a problem hiding this comment.
Shouldn't it be "Returns the default value of char which is \\x00?"
| default_impl! { bool, false } | ||
| default_impl! { char, '\x00' } | ||
| default_impl! { (), (), "Returns the default value of `()`" } | ||
| default_impl! { bool, false, "Returns the default value of `false`" } |
There was a problem hiding this comment.
Shouldn't it be "Returns the default value ofbool which is false?"
GuillaumeGomez
commented
Jul 16, 2017
Hum, actually I think it's good as is. The wording is lighter. I'll go for this one then. Thanks! @bors: r+ rollup |
bors
commented
Jul 16, 2017
📌 Commit caf125f has been approved by |
bors
commented
Jul 16, 2017
Document default values for primitive types All primitive types implement the `Default` trait but the documentation just says `Returns the "default value" for a type.` and doesn't give a hint about the actual default value. I think it would be good to document the default values in a proper way. I changed the `default_impl` macro to accept a doc string as a third parameter and use this string to overwrite the documentation of `default()` for each primitive type. The generated documentation now looks like this: 
bors
commented
Jul 16, 2017
☀️ Test successful - status-appveyor, status-travis |
After rust-lang#43252 is merged, building stage0 libcore with -i (--incremental) flag will cause 17 "Quasi-quoting might make incremental compilation very inefficient: NtExpr(..)" warnings, as in rust-lang#40946. Fixing the warning in rust-lang#40946 will take 12 weeks from now to make into the next stage0, so it is quicker to workaround it in libcore instead.
…n-rustbuild, r=alexcrichton Workaround "Quasi-quoting is inefficient" warning in incremental rustbuild introduced in rust-lang#43252. After rust-lang#43252 is merged, building stage0 libcore with `-i` (`--incremental`) flag will cause 17 "Quasi-quoting might make incremental compilation very inefficient: NtExpr(..)" warnings, as in rust-lang#40946. ``` warning: Quasi-quoting might make incremental compilation very inefficient: NtExpr(..) --> src/libcore/default.rs:133:21 | 133 | #[doc = $doc] | ^^^^ ... 139 | default_impl! { (), (), "Returns the default value of `()`" } | ------------------------------------------------------------- in this macro invocation (× 17) ``` True fix for rust-lang#40946 will take at least 12 weeks from now to make into the next stage0, so it is quicker to workaround it in libcore instead. cc @vbrandl@jseyfried
All primitive types implement the

Defaulttrait but the documentation just saysReturns the "default value" for a type.and doesn't give a hint about the actual default value. I think it would be good to document the default values in a proper way.I changed the
default_implmacro to accept a doc string as a third parameter and use this string to overwrite the documentation ofdefault()for each primitive type.The generated documentation now looks like this: