Rollup merge of #61134 - nvzqz:reverse_bits-must_use, r=varkor

Annotate each `reverse_bits` with `#[must_use]`

Because the name sounds like an in-place mutation like `[T]::reverse(&mut self)`, it may be confused for one.

This change was requested at https://github.com/rust-lang/rust/issues/48763#issuecomment-493743741.
This commit is contained in:
Mazdak Farrokhzad
2019-05-25 04:55:43 +02:00
committed by GitHub
2 changed files with 3 additions and 0 deletions

View File

@@ -473,6 +473,7 @@ assert_eq!(m, ", $reversed, ");
#[unstable(feature = "reverse_bits", issue = "48763")] #[unstable(feature = "reverse_bits", issue = "48763")]
#[rustc_const_unstable(feature = "const_int_conversion")] #[rustc_const_unstable(feature = "const_int_conversion")]
#[inline] #[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self { pub const fn reverse_bits(self) -> Self {
(self as $UnsignedT).reverse_bits() as Self (self as $UnsignedT).reverse_bits() as Self
} }
@@ -2522,6 +2523,7 @@ assert_eq!(m, ", $reversed, ");
```"), ```"),
#[unstable(feature = "reverse_bits", issue = "48763")] #[unstable(feature = "reverse_bits", issue = "48763")]
#[inline] #[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self { pub const fn reverse_bits(self) -> Self {
intrinsics::bitreverse(self as $ActualT) as Self intrinsics::bitreverse(self as $ActualT) as Self
} }

View File

@@ -524,6 +524,7 @@ assert_eq!(n.trailing_zeros(), 3);
/// ``` /// ```
#[unstable(feature = "reverse_bits", issue = "48763")] #[unstable(feature = "reverse_bits", issue = "48763")]
#[inline] #[inline]
#[must_use]
pub const fn reverse_bits(self) -> Self { pub const fn reverse_bits(self) -> Self {
Wrapping(self.0.reverse_bits()) Wrapping(self.0.reverse_bits())
} }