Skip to content

Commit 83ebe41

Browse files
authored
Rollup merge of rust-lang#84444 - notriddle:num-docs-from-undocumented-items-toggle, r=yaahc
doc: Get rid of "[+] show undocumented items" toggle on numeric From impls On most From implementations, the docstring is attached to the function. This is also how people have been [recommended] to do it. Screenshots: * [before](https://user-images.githubusercontent.com/1593513/115767662-323c5480-a35e-11eb-9918-98aba83e9183.png) * [after](https://user-images.githubusercontent.com/1593513/115767675-35374500-a35e-11eb-964f-c28eeb6c807a.png) [recommended]: rust-lang#51430 (comment)
2 parents 2a2b15a + c247055 commit 83ebe41

File tree

1 file changed

+12
-4
lines changed
  • library/core/src/convert

1 file changed

+12
-4
lines changed

library/core/src/convert/num.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ impl_float_to_int!(f64 => u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
4545
macro_rules! impl_from {
4646
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
4747
#[$attr]
48-
#[doc = $doc]
4948
impl From<$Small> for $Large {
49+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
50+
// Rustdocs on functions do not.
51+
#[doc = $doc]
5052
#[inline]
5153
fn from(small: $Small) -> Self {
5254
small as Self
@@ -383,8 +385,10 @@ use crate::num::NonZeroUsize;
383385
macro_rules! nzint_impl_from {
384386
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
385387
#[$attr]
386-
#[doc = $doc]
387388
impl From<$Small> for $Large {
389+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
390+
// Rustdocs on functions do not.
391+
#[doc = $doc]
388392
#[inline]
389393
fn from(small: $Small) -> Self {
390394
// SAFETY: input type guarantees the value is non-zero
@@ -450,10 +454,12 @@ nzint_impl_from! { NonZeroU64, NonZeroI128, #[stable(feature = "nz_int_conv", si
450454
macro_rules! nzint_impl_try_from_int {
451455
($Int: ty, $NonZeroInt: ty, #[$attr:meta], $doc: expr) => {
452456
#[$attr]
453-
#[doc = $doc]
454457
impl TryFrom<$Int> for $NonZeroInt {
455458
type Error = TryFromIntError;
456459

460+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
461+
// Rustdocs on functions do not.
462+
#[doc = $doc]
457463
#[inline]
458464
fn try_from(value: $Int) -> Result<Self, Self::Error> {
459465
Self::new(value).ok_or(TryFromIntError(()))
@@ -489,10 +495,12 @@ nzint_impl_try_from_int! { isize, NonZeroIsize, #[stable(feature = "nzint_try_fr
489495
macro_rules! nzint_impl_try_from_nzint {
490496
($From:ty => $To:ty, $doc: expr) => {
491497
#[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")]
492-
#[doc = $doc]
493498
impl TryFrom<$From> for $To {
494499
type Error = TryFromIntError;
495500

501+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
502+
// Rustdocs on functions do not.
503+
#[doc = $doc]
496504
#[inline]
497505
fn try_from(value: $From) -> Result<Self, Self::Error> {
498506
TryFrom::try_from(value.get()).map(|v| {

0 commit comments

Comments
 (0)