Skip to content

Commit 5694b8e

Browse files
committed
Don't use doc_comment!{} hack in nonzero_leading_trailing_zeros!{}.
1 parent 27b81bf commit 5694b8e

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

library/core/src/num/nonzero.rs

+41-45
Original file line numberDiff line numberDiff line change
@@ -182,53 +182,49 @@ macro_rules! nonzero_leading_trailing_zeros {
182182
( $( $Ty: ident($Uint: ty) , $LeadingTestExpr:expr ;)+ ) => {
183183
$(
184184
impl $Ty {
185-
doc_comment! {
186-
concat!("Returns the number of leading zeros in the binary representation of `self`.
187-
188-
On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided.
189-
190-
# Examples
191-
192-
Basic usage:
193-
194-
```
195-
#![feature(nonzero_leading_trailing_zeros)]
196-
let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap();
197-
198-
assert_eq!(n.leading_zeros(), 0);
199-
```"),
200-
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
201-
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
202-
#[inline]
203-
pub const fn leading_zeros(self) -> u32 {
204-
// SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero
205-
unsafe { intrinsics::ctlz_nonzero(self.0 as $Uint) as u32 }
206-
}
185+
/// Returns the number of leading zeros in the binary representation of `self`.
186+
///
187+
/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided.
188+
///
189+
/// # Examples
190+
///
191+
/// Basic usage:
192+
///
193+
/// ```
194+
/// #![feature(nonzero_leading_trailing_zeros)]
195+
#[doc = concat!("let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap();")]
196+
///
197+
/// assert_eq!(n.leading_zeros(), 0);
198+
/// ```
199+
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
200+
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
201+
#[inline]
202+
pub const fn leading_zeros(self) -> u32 {
203+
// SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero
204+
unsafe { intrinsics::ctlz_nonzero(self.0 as $Uint) as u32 }
207205
}
208206

209-
doc_comment! {
210-
concat!("Returns the number of trailing zeros in the binary representation
211-
of `self`.
212-
213-
On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided.
214-
215-
# Examples
216-
217-
Basic usage:
218-
219-
```
220-
#![feature(nonzero_leading_trailing_zeros)]
221-
let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap();
222-
223-
assert_eq!(n.trailing_zeros(), 3);
224-
```"),
225-
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
226-
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
227-
#[inline]
228-
pub const fn trailing_zeros(self) -> u32 {
229-
// SAFETY: since `self` can not be zero it is safe to call cttz_nonzero
230-
unsafe { intrinsics::cttz_nonzero(self.0 as $Uint) as u32 }
231-
}
207+
/// Returns the number of trailing zeros in the binary representation
208+
/// of `self`.
209+
///
210+
/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided.
211+
///
212+
/// # Examples
213+
///
214+
/// Basic usage:
215+
///
216+
/// ```
217+
/// #![feature(nonzero_leading_trailing_zeros)]
218+
#[doc = concat!("let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap();")]
219+
///
220+
/// assert_eq!(n.trailing_zeros(), 3);
221+
/// ```
222+
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
223+
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
224+
#[inline]
225+
pub const fn trailing_zeros(self) -> u32 {
226+
// SAFETY: since `self` can not be zero it is safe to call cttz_nonzero
227+
unsafe { intrinsics::cttz_nonzero(self.0 as $Uint) as u32 }
232228
}
233229

234230
}

0 commit comments

Comments
 (0)