Auto merge of #89739 - matthiaskrgr:rollup-kskwqy5, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #88374 (Fix documentation in Cell) - #88713 (Improve docs for int_log) - #89428 (Feature gate the non_exhaustive_omitted_patterns lint) - #89438 (docs: `std:#️⃣:Hash` should ensure prefix-free data) - #89520 (Don't rebuild GUI test crates every time you run test src/test/rustdoc-gui) - #89705 (Cfg hide no_global_oom_handling and no_fp_fmt_parse) - #89713 (Fix ABNF of inline asm options) - #89718 (Add #[must_use] to is_condition tests) - #89719 (Add #[must_use] to char escape methods) - #89720 (Add #[must_use] to math and bit manipulation methods) - #89735 (Stabilize proc_macro::is_available) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
41dfaaa3c6
28 changed files with 518 additions and 71 deletions
|
@ -678,6 +678,9 @@ declare_features! (
|
|||
/// Allows `#[doc(cfg_hide(...))]`.
|
||||
(active, doc_cfg_hide, "1.57.0", Some(43781), None),
|
||||
|
||||
/// Allows using the `non_exhaustive_omitted_patterns` lint.
|
||||
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-end: actual feature gates
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
declare_lint! {
|
||||
/// The `forbidden_lint_groups` lint detects violations of
|
||||
|
@ -3476,6 +3477,8 @@ declare_lint! {
|
|||
/// }
|
||||
///
|
||||
/// // in crate B
|
||||
/// #![feature(non_exhaustive_omitted_patterns_lint)]
|
||||
///
|
||||
/// match Bar::A {
|
||||
/// Bar::A => {},
|
||||
/// #[warn(non_exhaustive_omitted_patterns)]
|
||||
|
@ -3512,6 +3515,7 @@ declare_lint! {
|
|||
pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
|
||||
Allow,
|
||||
"detect when patterns of types marked `non_exhaustive` are missed",
|
||||
@feature_gate = sym::non_exhaustive_omitted_patterns_lint;
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
|
|
|
@ -893,6 +893,7 @@ symbols! {
|
|||
nomem,
|
||||
non_ascii_idents,
|
||||
non_exhaustive,
|
||||
non_exhaustive_omitted_patterns_lint,
|
||||
non_modrs_mods,
|
||||
none_error,
|
||||
nontemporal_store,
|
||||
|
|
|
@ -534,6 +534,7 @@ impl<T> BTreeSet<T> {
|
|||
/// b.insert(1);
|
||||
/// assert_eq!(a.is_disjoint(&b), false);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool
|
||||
where
|
||||
|
@ -559,6 +560,7 @@ impl<T> BTreeSet<T> {
|
|||
/// set.insert(4);
|
||||
/// assert_eq!(set.is_subset(&sup), false);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_subset(&self, other: &BTreeSet<T>) -> bool
|
||||
where
|
||||
|
@ -638,6 +640,7 @@ impl<T> BTreeSet<T> {
|
|||
/// set.insert(2);
|
||||
/// assert_eq!(set.is_superset(&sub), true);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_superset(&self, other: &BTreeSet<T>) -> bool
|
||||
where
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
not(test),
|
||||
not(any(test, bootstrap)),
|
||||
any(not(feature = "miri-test-libstd"), test, doctest),
|
||||
no_global_oom_handling,
|
||||
target_has_atomic = "ptr"
|
||||
))
|
||||
)]
|
||||
|
|
|
@ -349,7 +349,7 @@ impl<T> Cell<T> {
|
|||
drop(old);
|
||||
}
|
||||
|
||||
/// Swaps the values of two Cells.
|
||||
/// Swaps the values of two `Cell`s.
|
||||
/// Difference with `std::mem::swap` is that this function doesn't require `&mut` reference.
|
||||
///
|
||||
/// # Examples
|
||||
|
|
|
@ -377,6 +377,8 @@ impl char {
|
|||
/// ```
|
||||
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
|
||||
/// ```
|
||||
#[must_use = "this returns the escaped char as an iterator, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn escape_unicode(self) -> EscapeUnicode {
|
||||
|
@ -453,6 +455,8 @@ impl char {
|
|||
/// ```
|
||||
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
|
||||
/// ```
|
||||
#[must_use = "this returns the escaped char as an iterator, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "char_escape_debug", since = "1.20.0")]
|
||||
#[inline]
|
||||
pub fn escape_debug(self) -> EscapeDebug {
|
||||
|
@ -507,6 +511,8 @@ impl char {
|
|||
/// ```
|
||||
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
|
||||
/// ```
|
||||
#[must_use = "this returns the escaped char as an iterator, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn escape_default(self) -> EscapeDefault {
|
||||
|
@ -692,6 +698,7 @@ impl char {
|
|||
/// // love is many things, but it is not alphabetic
|
||||
/// assert!(!c.is_alphabetic());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_alphabetic(self) -> bool {
|
||||
|
@ -724,6 +731,7 @@ impl char {
|
|||
/// assert!(!'中'.is_lowercase());
|
||||
/// assert!(!' '.is_lowercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_lowercase(self) -> bool {
|
||||
|
@ -756,6 +764,7 @@ impl char {
|
|||
/// assert!(!'中'.is_uppercase());
|
||||
/// assert!(!' '.is_uppercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_uppercase(self) -> bool {
|
||||
|
@ -784,6 +793,7 @@ impl char {
|
|||
///
|
||||
/// assert!(!'越'.is_whitespace());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_whitespace(self) -> bool {
|
||||
|
@ -812,6 +822,7 @@ impl char {
|
|||
/// assert!('و'.is_alphanumeric());
|
||||
/// assert!('藏'.is_alphanumeric());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_alphanumeric(self) -> bool {
|
||||
|
@ -837,6 +848,7 @@ impl char {
|
|||
/// assert!(''.is_control());
|
||||
/// assert!(!'q'.is_control());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_control(self) -> bool {
|
||||
|
@ -852,6 +864,7 @@ impl char {
|
|||
/// [uax29]: https://www.unicode.org/reports/tr29/
|
||||
/// [ucd]: https://www.unicode.org/reports/tr44/
|
||||
/// [`DerivedCoreProperties.txt`]: https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub(crate) fn is_grapheme_extended(self) -> bool {
|
||||
unicode::Grapheme_Extend(self)
|
||||
|
@ -881,6 +894,7 @@ impl char {
|
|||
/// assert!(!'و'.is_numeric());
|
||||
/// assert!(!'藏'.is_numeric());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_numeric(self) -> bool {
|
||||
|
@ -1060,6 +1074,7 @@ impl char {
|
|||
/// assert!(ascii.is_ascii());
|
||||
/// assert!(!non_ascii.is_ascii());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.32.0")]
|
||||
#[inline]
|
||||
|
@ -1237,6 +1252,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_alphabetic());
|
||||
/// assert!(!esc.is_ascii_alphabetic());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1270,6 +1286,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_uppercase());
|
||||
/// assert!(!esc.is_ascii_uppercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1303,6 +1320,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_lowercase());
|
||||
/// assert!(!esc.is_ascii_lowercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1339,6 +1357,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_alphanumeric());
|
||||
/// assert!(!esc.is_ascii_alphanumeric());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1372,6 +1391,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_digit());
|
||||
/// assert!(!esc.is_ascii_digit());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1408,6 +1428,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_hexdigit());
|
||||
/// assert!(!esc.is_ascii_hexdigit());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1445,6 +1466,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_punctuation());
|
||||
/// assert!(!esc.is_ascii_punctuation());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1478,6 +1500,7 @@ impl char {
|
|||
/// assert!(!lf.is_ascii_graphic());
|
||||
/// assert!(!esc.is_ascii_graphic());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1528,6 +1551,7 @@ impl char {
|
|||
/// assert!(lf.is_ascii_whitespace());
|
||||
/// assert!(!esc.is_ascii_whitespace());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -1563,6 +1587,7 @@ impl char {
|
|||
/// assert!(lf.is_ascii_control());
|
||||
/// assert!(esc.is_ascii_control());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
|
|
@ -153,9 +153,21 @@ mod sip;
|
|||
/// Thankfully, you won't need to worry about upholding this property when
|
||||
/// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`.
|
||||
///
|
||||
/// ## Prefix collisions
|
||||
///
|
||||
/// Implementations of `hash` should ensure that the data they
|
||||
/// pass to the `Hasher` are prefix-free. That is,
|
||||
/// unequal values should cause two different sequences of values to be written,
|
||||
/// and neither of the two sequences should be a prefix of the other.
|
||||
///
|
||||
/// For example, the standard implementation of [`Hash` for `&str`][impl] passes an extra
|
||||
/// `0xFF` byte to the `Hasher` so that the values `("ab", "c")` and `("a",
|
||||
/// "bc")` hash differently.
|
||||
///
|
||||
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
|
||||
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
|
||||
/// [`hash`]: Hash::hash
|
||||
/// [impl]: ../../std/primitive.str.html#impl-Hash
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "Hash"]
|
||||
pub trait Hash {
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
doc(cfg_hide(
|
||||
not(test),
|
||||
any(not(feature = "miri-test-libstd"), test, doctest),
|
||||
no_fp_fmt_parse,
|
||||
target_pointer_width = "16",
|
||||
target_pointer_width = "32",
|
||||
target_pointer_width = "64",
|
||||
|
|
|
@ -436,6 +436,7 @@ impl f32 {
|
|||
/// assert!(nan.is_nan());
|
||||
/// assert!(!f.is_nan());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -467,6 +468,7 @@ impl f32 {
|
|||
/// assert!(inf.is_infinite());
|
||||
/// assert!(neg_inf.is_infinite());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -488,6 +490,7 @@ impl f32 {
|
|||
/// assert!(!inf.is_finite());
|
||||
/// assert!(!neg_inf.is_finite());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -515,6 +518,7 @@ impl f32 {
|
|||
/// assert!(lower_than_min.is_subnormal());
|
||||
/// ```
|
||||
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
|
||||
#[must_use]
|
||||
#[stable(feature = "is_subnormal", since = "1.53.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -541,6 +545,7 @@ impl f32 {
|
|||
/// assert!(!lower_than_min.is_normal());
|
||||
/// ```
|
||||
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -587,6 +592,7 @@ impl f32 {
|
|||
/// assert!(f.is_sign_positive());
|
||||
/// assert!(!g.is_sign_positive());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -604,6 +610,7 @@ impl f32 {
|
|||
/// assert!(!f.is_sign_negative());
|
||||
/// assert!(g.is_sign_negative());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -636,6 +643,8 @@ impl f32 {
|
|||
///
|
||||
/// assert!(abs_difference <= f32::EPSILON);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
|
||||
#[inline]
|
||||
pub fn to_degrees(self) -> f32 {
|
||||
|
@ -653,6 +662,8 @@ impl f32 {
|
|||
///
|
||||
/// assert!(abs_difference <= f32::EPSILON);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
|
||||
#[inline]
|
||||
pub fn to_radians(self) -> f32 {
|
||||
|
@ -712,6 +723,8 @@ impl f32 {
|
|||
/// * Not be `NaN`
|
||||
/// * Not be infinite
|
||||
/// * Be representable in the return type `Int`, after truncating off its fractional part
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_approx_unchecked_to", since = "1.44.0")]
|
||||
#[inline]
|
||||
pub unsafe fn to_int_unchecked<Int>(self) -> Int
|
||||
|
@ -740,6 +753,8 @@ impl f32 {
|
|||
/// assert_eq!((12.5f32).to_bits(), 0x41480000);
|
||||
///
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_bits_conv", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -802,6 +817,8 @@ impl f32 {
|
|||
/// let bytes = 12.5f32.to_be_bytes();
|
||||
/// assert_eq!(bytes, [0x41, 0x48, 0x00, 0x00]);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -818,6 +835,8 @@ impl f32 {
|
|||
/// let bytes = 12.5f32.to_le_bytes();
|
||||
/// assert_eq!(bytes, [0x00, 0x00, 0x48, 0x41]);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -847,6 +866,8 @@ impl f32 {
|
|||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
|
|
@ -435,6 +435,7 @@ impl f64 {
|
|||
/// assert!(nan.is_nan());
|
||||
/// assert!(!f.is_nan());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -466,6 +467,7 @@ impl f64 {
|
|||
/// assert!(inf.is_infinite());
|
||||
/// assert!(neg_inf.is_infinite());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -487,6 +489,7 @@ impl f64 {
|
|||
/// assert!(!inf.is_finite());
|
||||
/// assert!(!neg_inf.is_finite());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -514,6 +517,7 @@ impl f64 {
|
|||
/// assert!(lower_than_min.is_subnormal());
|
||||
/// ```
|
||||
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
|
||||
#[must_use]
|
||||
#[stable(feature = "is_subnormal", since = "1.53.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -540,6 +544,7 @@ impl f64 {
|
|||
/// assert!(!lower_than_min.is_normal());
|
||||
/// ```
|
||||
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -586,6 +591,7 @@ impl f64 {
|
|||
/// assert!(f.is_sign_positive());
|
||||
/// assert!(!g.is_sign_positive());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -593,6 +599,7 @@ impl f64 {
|
|||
!self.is_sign_negative()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_positive")]
|
||||
#[inline]
|
||||
|
@ -611,6 +618,7 @@ impl f64 {
|
|||
/// assert!(!f.is_sign_negative());
|
||||
/// assert!(g.is_sign_negative());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
|
||||
#[inline]
|
||||
|
@ -618,6 +626,7 @@ impl f64 {
|
|||
self.to_bits() & 0x8000_0000_0000_0000 != 0
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_negative")]
|
||||
#[inline]
|
||||
|
@ -649,6 +658,8 @@ impl f64 {
|
|||
///
|
||||
/// assert!(abs_difference < 1e-10);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_degrees(self) -> f64 {
|
||||
|
@ -667,6 +678,8 @@ impl f64 {
|
|||
///
|
||||
/// assert!(abs_difference < 1e-10);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_radians(self) -> f64 {
|
||||
|
@ -726,6 +739,8 @@ impl f64 {
|
|||
/// * Not be `NaN`
|
||||
/// * Not be infinite
|
||||
/// * Be representable in the return type `Int`, after truncating off its fractional part
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_approx_unchecked_to", since = "1.44.0")]
|
||||
#[inline]
|
||||
pub unsafe fn to_int_unchecked<Int>(self) -> Int
|
||||
|
@ -754,6 +769,8 @@ impl f64 {
|
|||
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
|
||||
///
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_bits_conv", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -816,6 +833,8 @@ impl f64 {
|
|||
/// let bytes = 12.5f64.to_be_bytes();
|
||||
/// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -832,6 +851,8 @@ impl f64 {
|
|||
/// let bytes = 12.5f64.to_le_bytes();
|
||||
/// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
@ -861,6 +882,8 @@ impl f64 {
|
|||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[inline]
|
||||
|
|
|
@ -81,6 +81,8 @@ macro_rules! int_impl {
|
|||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[doc(alias = "popcount")]
|
||||
#[doc(alias = "popcnt")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
|
||||
|
||||
|
@ -95,6 +97,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn count_zeros(self) -> u32 {
|
||||
(!self).count_ones()
|
||||
|
@ -113,6 +117,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).leading_zeros()
|
||||
|
@ -131,6 +137,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn trailing_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).trailing_zeros()
|
||||
|
@ -149,6 +157,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn leading_ones(self) -> u32 {
|
||||
(self as $UnsignedT).leading_ones()
|
||||
|
@ -167,6 +177,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn trailing_ones(self) -> u32 {
|
||||
(self as $UnsignedT).trailing_ones()
|
||||
|
@ -236,6 +248,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn swap_bytes(self) -> Self {
|
||||
(self as $UnsignedT).swap_bytes() as Self
|
||||
|
@ -257,8 +271,9 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "reverse_bits", since = "1.37.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.37.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn reverse_bits(self) -> Self {
|
||||
(self as $UnsignedT).reverse_bits() as Self
|
||||
}
|
||||
|
@ -344,6 +359,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversions", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_be(self) -> Self { // or not to be?
|
||||
#[cfg(target_endian = "big")]
|
||||
|
@ -375,6 +392,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversions", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_le(self) -> Self {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
@ -689,6 +708,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "wrapping", since = "1.7.0")]
|
||||
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_neg(self) -> Option<Self> {
|
||||
let (a, b) = self.overflowing_neg();
|
||||
|
@ -801,6 +822,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "no_panic_abs", since = "1.13.0")]
|
||||
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_abs(self) -> Option<Self> {
|
||||
if self.is_negative() {
|
||||
|
@ -959,6 +982,8 @@ macro_rules! int_impl {
|
|||
|
||||
#[stable(feature = "saturating_neg", since = "1.45.0")]
|
||||
#[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn saturating_neg(self) -> Self {
|
||||
intrinsics::saturating_sub(0, self)
|
||||
|
@ -980,6 +1005,8 @@ macro_rules! int_impl {
|
|||
|
||||
#[stable(feature = "saturating_neg", since = "1.45.0")]
|
||||
#[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn saturating_abs(self) -> Self {
|
||||
if self.is_negative() {
|
||||
|
@ -1308,6 +1335,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "num_wrapping", since = "1.2.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn wrapping_neg(self) -> Self {
|
||||
(0 as $SelfT).wrapping_sub(self)
|
||||
|
@ -1390,6 +1419,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "no_panic_abs", since = "1.13.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[allow(unused_attributes)]
|
||||
#[inline]
|
||||
pub const fn wrapping_abs(self) -> Self {
|
||||
|
@ -1415,6 +1446,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "unsigned_abs", since = "1.51.0")]
|
||||
#[rustc_const_stable(feature = "unsigned_abs", since = "1.51.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn unsigned_abs(self) -> $UnsignedT {
|
||||
self.wrapping_abs() as $UnsignedT
|
||||
|
@ -1781,6 +1814,8 @@ macro_rules! int_impl {
|
|||
#[inline]
|
||||
#[stable(feature = "wrapping", since = "1.7.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[allow(unused_attributes)]
|
||||
pub const fn overflowing_neg(self) -> (Self, bool) {
|
||||
if unlikely!(self == Self::MIN) {
|
||||
|
@ -1855,6 +1890,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "no_panic_abs", since = "1.13.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn overflowing_abs(self) -> (Self, bool) {
|
||||
(self.wrapping_abs(), self == Self::MIN)
|
||||
|
@ -2199,7 +2236,8 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base,
|
||||
/// rounded down.
|
||||
///
|
||||
/// This method might not be optimized owing to implementation details;
|
||||
/// `log2` can produce results more efficiently for base 2, and `log10`
|
||||
|
@ -2208,8 +2246,8 @@ macro_rules! int_impl {
|
|||
/// # Panics
|
||||
///
|
||||
/// When the number is zero, or if the base is not at least 2; it
|
||||
/// panics in debug mode and the return value is wrapped to 0 in release
|
||||
/// mode (the only situation in which the method can return 0).
|
||||
/// panics in debug mode and the return value is 0 in release
|
||||
/// mode.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -2219,7 +2257,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -2237,13 +2275,12 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 2 logarithm of the number.
|
||||
/// Returns the base 2 logarithm of the number, rounded down.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// When the number is zero it panics in debug mode and the return value
|
||||
/// is wrapped to 0 in release mode (the only situation in which the
|
||||
/// method can return 0).
|
||||
/// is 0 in release mode.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -2253,7 +2290,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -2271,13 +2308,12 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 10 logarithm of the number.
|
||||
/// Returns the base 10 logarithm of the number, rounded down.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// When the number is zero it panics in debug mode and the return value
|
||||
/// is wrapped to 0 in release mode (the only situation in which the
|
||||
/// method can return 0).
|
||||
/// is 0 in release mode.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -2287,7 +2323,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -2305,7 +2341,8 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base,
|
||||
/// rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
|
||||
///
|
||||
|
@ -2321,7 +2358,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log(self, base: Self) -> Option<u32> {
|
||||
if self <= 0 || base <= 1 {
|
||||
|
@ -2345,7 +2382,7 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 2 logarithm of the number.
|
||||
/// Returns the base 2 logarithm of the number, rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is negative or zero.
|
||||
///
|
||||
|
@ -2357,7 +2394,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log2(self) -> Option<u32> {
|
||||
if self <= 0 {
|
||||
|
@ -2369,7 +2406,7 @@ macro_rules! int_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 10 logarithm of the number.
|
||||
/// Returns the base 10 logarithm of the number, rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is negative or zero.
|
||||
///
|
||||
|
@ -2381,7 +2418,7 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log10(self) -> Option<u32> {
|
||||
int_log10::$ActualT(self as $ActualT)
|
||||
|
@ -2412,6 +2449,8 @@ macro_rules! int_impl {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[allow(unused_attributes)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn abs(self) -> Self {
|
||||
|
@ -2443,6 +2482,8 @@ macro_rules! int_impl {
|
|||
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.abs_diff(", stringify!($SelfT), "::MAX), ", stringify!($UnsignedT), "::MAX);")]
|
||||
/// ```
|
||||
#[unstable(feature = "int_abs_diff", issue = "89492")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn abs_diff(self, other: Self) -> $UnsignedT {
|
||||
if self < other {
|
||||
|
@ -2482,6 +2523,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_sign", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn signum(self) -> Self {
|
||||
match self {
|
||||
|
@ -2502,6 +2545,7 @@ macro_rules! int_impl {
|
|||
#[doc = concat!("assert!(10", stringify!($SelfT), ".is_positive());")]
|
||||
#[doc = concat!("assert!(!(-10", stringify!($SelfT), ").is_positive());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[inline(always)]
|
||||
|
@ -2518,6 +2562,7 @@ macro_rules! int_impl {
|
|||
#[doc = concat!("assert!((-10", stringify!($SelfT), ").is_negative());")]
|
||||
#[doc = concat!("assert!(!10", stringify!($SelfT), ".is_negative());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
|
||||
#[inline(always)]
|
||||
|
@ -2536,6 +2581,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
||||
self.to_be().to_ne_bytes()
|
||||
|
@ -2554,6 +2601,8 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
||||
self.to_le().to_ne_bytes()
|
||||
|
@ -2588,6 +2637,8 @@ macro_rules! int_impl {
|
|||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
// SAFETY: const sound because integers are plain old datatypes so we can always
|
||||
// transmute them to arrays of bytes
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
||||
// SAFETY: integers are plain old datatypes so we can always transmute them to
|
||||
|
|
|
@ -259,6 +259,7 @@ impl u8 {
|
|||
/// assert!(ascii.is_ascii());
|
||||
/// assert!(!non_ascii.is_ascii());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.43.0")]
|
||||
#[inline]
|
||||
|
@ -419,6 +420,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_alphabetic());
|
||||
/// assert!(!esc.is_ascii_alphabetic());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -452,6 +454,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_uppercase());
|
||||
/// assert!(!esc.is_ascii_uppercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -485,6 +488,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_lowercase());
|
||||
/// assert!(!esc.is_ascii_lowercase());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -521,6 +525,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_alphanumeric());
|
||||
/// assert!(!esc.is_ascii_alphanumeric());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -554,6 +559,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_digit());
|
||||
/// assert!(!esc.is_ascii_digit());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -590,6 +596,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_hexdigit());
|
||||
/// assert!(!esc.is_ascii_hexdigit());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -627,6 +634,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_punctuation());
|
||||
/// assert!(!esc.is_ascii_punctuation());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -660,6 +668,7 @@ impl u8 {
|
|||
/// assert!(!lf.is_ascii_graphic());
|
||||
/// assert!(!esc.is_ascii_graphic());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -710,6 +719,7 @@ impl u8 {
|
|||
/// assert!(lf.is_ascii_whitespace());
|
||||
/// assert!(!esc.is_ascii_whitespace());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
@ -745,6 +755,7 @@ impl u8 {
|
|||
/// assert!(lf.is_ascii_control());
|
||||
/// assert!(esc.is_ascii_control());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
|
||||
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
|
||||
#[inline]
|
||||
|
|
|
@ -198,6 +198,8 @@ macro_rules! nonzero_leading_trailing_zeros {
|
|||
/// ```
|
||||
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
|
||||
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
// SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero
|
||||
|
@ -220,6 +222,8 @@ macro_rules! nonzero_leading_trailing_zeros {
|
|||
/// ```
|
||||
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
|
||||
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn trailing_zeros(self) -> u32 {
|
||||
// SAFETY: since `self` can not be zero it is safe to call cttz_nonzero
|
||||
|
@ -315,6 +319,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_add(self, other: $Int) -> Option<$Ty> {
|
||||
if let Some(result) = self.get().checked_add(other) {
|
||||
|
@ -348,6 +354,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn saturating_add(self, other: $Int) -> $Ty {
|
||||
// SAFETY: $Int::saturating_add returns $Int::MAX on overflow
|
||||
|
@ -378,6 +386,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
|
||||
// SAFETY: The caller ensures there is no overflow.
|
||||
|
@ -410,6 +420,8 @@ macro_rules! nonzero_unsigned_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_next_power_of_two(self) -> Option<$Ty> {
|
||||
if let Some(nz) = self.get().checked_next_power_of_two() {
|
||||
|
@ -460,6 +472,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn abs(self) -> $Ty {
|
||||
// SAFETY: This cannot overflow to zero.
|
||||
|
@ -490,6 +504,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_abs(self) -> Option<$Ty> {
|
||||
if let Some(nz) = self.get().checked_abs() {
|
||||
|
@ -524,6 +540,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn overflowing_abs(self) -> ($Ty, bool) {
|
||||
let (nz, flag) = self.get().overflowing_abs();
|
||||
|
@ -562,6 +580,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn saturating_abs(self) -> $Ty {
|
||||
// SAFETY: absolute value of nonzero cannot yield zero values.
|
||||
|
@ -595,6 +615,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn wrapping_abs(self) -> $Ty {
|
||||
// SAFETY: absolute value of nonzero cannot yield zero values.
|
||||
|
@ -628,6 +650,8 @@ macro_rules! nonzero_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn unsigned_abs(self) -> $Uty {
|
||||
// SAFETY: absolute value of nonzero cannot yield zero values.
|
||||
|
@ -675,6 +699,8 @@ macro_rules! nonzero_unsigned_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_mul(self, other: $Ty) -> Option<$Ty> {
|
||||
if let Some(result) = self.get().checked_mul(other.get()) {
|
||||
|
@ -709,6 +735,8 @@ macro_rules! nonzero_unsigned_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn saturating_mul(self, other: $Ty) -> $Ty {
|
||||
// SAFETY: saturating_mul returns u*::MAX on overflow
|
||||
|
@ -749,6 +777,8 @@ macro_rules! nonzero_unsigned_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
|
||||
// SAFETY: The caller ensures there is no overflow.
|
||||
|
@ -778,6 +808,8 @@ macro_rules! nonzero_unsigned_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_pow(self, other: u32) -> Option<$Ty> {
|
||||
if let Some(result) = self.get().checked_pow(other) {
|
||||
|
@ -820,6 +852,8 @@ macro_rules! nonzero_unsigned_signed_operations {
|
|||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn saturating_pow(self, other: u32) -> $Ty {
|
||||
// SAFETY: saturating_pow returns u*::MAX on overflow
|
||||
|
@ -878,6 +912,7 @@ macro_rules! nonzero_unsigned_is_power_of_two {
|
|||
#[doc = concat!("let ten = std::num::", stringify!($Ty), "::new(10).unwrap();")]
|
||||
/// assert!(!ten.is_power_of_two());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[unstable(feature = "nonzero_is_power_of_two", issue = "81106")]
|
||||
#[inline]
|
||||
pub const fn is_power_of_two(self) -> bool {
|
||||
|
|
|
@ -474,6 +474,8 @@ macro_rules! saturating_int_impl {
|
|||
#[inline]
|
||||
#[doc(alias = "popcount")]
|
||||
#[doc(alias = "popcnt")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn count_ones(self) -> u32 {
|
||||
self.0.count_ones()
|
||||
|
@ -492,6 +494,8 @@ macro_rules! saturating_int_impl {
|
|||
#[doc = concat!("assert_eq!(Saturating(!0", stringify!($t), ").count_zeros(), 0);")]
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn count_zeros(self) -> u32 {
|
||||
self.0.count_zeros()
|
||||
|
@ -512,6 +516,8 @@ macro_rules! saturating_int_impl {
|
|||
/// assert_eq!(n.trailing_zeros(), 3);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn trailing_zeros(self) -> u32 {
|
||||
self.0.trailing_zeros()
|
||||
|
@ -538,6 +544,8 @@ macro_rules! saturating_int_impl {
|
|||
/// assert_eq!(n.rotate_left(32), m);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn rotate_left(self, n: u32) -> Self {
|
||||
Saturating(self.0.rotate_left(n))
|
||||
|
@ -564,6 +572,8 @@ macro_rules! saturating_int_impl {
|
|||
/// assert_eq!(n.rotate_right(4), m);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn rotate_right(self, n: u32) -> Self {
|
||||
Saturating(self.0.rotate_right(n))
|
||||
|
@ -588,6 +598,8 @@ macro_rules! saturating_int_impl {
|
|||
/// assert_eq!(m, Saturating(21760));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn swap_bytes(self) -> Self {
|
||||
Saturating(self.0.swap_bytes())
|
||||
|
@ -614,10 +626,11 @@ macro_rules! saturating_int_impl {
|
|||
/// assert_eq!(m.0 as u16, 0b10101010_00000000);
|
||||
/// assert_eq!(m, Saturating(-22016));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[rustc_const_stable(feature = "const_reverse_bits", since = "1.37.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn reverse_bits(self) -> Self {
|
||||
Saturating(self.0.reverse_bits())
|
||||
}
|
||||
|
@ -699,6 +712,8 @@ macro_rules! saturating_int_impl {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn to_be(self) -> Self {
|
||||
Saturating(self.0.to_be())
|
||||
}
|
||||
|
@ -726,6 +741,8 @@ macro_rules! saturating_int_impl {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn to_le(self) -> Self {
|
||||
Saturating(self.0.to_le())
|
||||
}
|
||||
|
@ -754,6 +771,8 @@ macro_rules! saturating_int_impl {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub fn pow(self, exp: u32) -> Self {
|
||||
Saturating(self.0.saturating_pow(exp))
|
||||
}
|
||||
|
@ -782,6 +801,8 @@ macro_rules! saturating_int_impl_signed {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
self.0.leading_zeros()
|
||||
}
|
||||
|
@ -805,6 +826,8 @@ macro_rules! saturating_int_impl_signed {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub fn abs(self) -> Saturating<$t> {
|
||||
Saturating(self.0.saturating_abs())
|
||||
}
|
||||
|
@ -829,6 +852,8 @@ macro_rules! saturating_int_impl_signed {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub fn signum(self) -> Saturating<$t> {
|
||||
Saturating(self.0.signum())
|
||||
}
|
||||
|
@ -847,6 +872,7 @@ macro_rules! saturating_int_impl_signed {
|
|||
#[doc = concat!("assert!(Saturating(10", stringify!($t), ").is_positive());")]
|
||||
#[doc = concat!("assert!(!Saturating(-10", stringify!($t), ").is_positive());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn is_positive(self) -> bool {
|
||||
|
@ -867,6 +893,7 @@ macro_rules! saturating_int_impl_signed {
|
|||
#[doc = concat!("assert!(Saturating(-10", stringify!($t), ").is_negative());")]
|
||||
#[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_negative());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn is_negative(self) -> bool {
|
||||
|
@ -908,6 +935,8 @@ macro_rules! saturating_int_impl_unsigned {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
self.0.leading_zeros()
|
||||
}
|
||||
|
@ -925,6 +954,7 @@ macro_rules! saturating_int_impl_unsigned {
|
|||
#[doc = concat!("assert!(Saturating(16", stringify!($t), ").is_power_of_two());")]
|
||||
#[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_power_of_two());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub fn is_power_of_two(self) -> bool {
|
||||
|
|
|
@ -80,6 +80,8 @@ macro_rules! uint_impl {
|
|||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[doc(alias = "popcount")]
|
||||
#[doc(alias = "popcnt")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn count_ones(self) -> u32 {
|
||||
intrinsics::ctpop(self as $ActualT) as u32
|
||||
|
@ -96,6 +98,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn count_zeros(self) -> u32 {
|
||||
(!self).count_ones()
|
||||
|
@ -114,6 +118,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
intrinsics::ctlz(self as $ActualT) as u32
|
||||
|
@ -133,6 +139,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn trailing_zeros(self) -> u32 {
|
||||
intrinsics::cttz(self) as u32
|
||||
|
@ -151,6 +159,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn leading_ones(self) -> u32 {
|
||||
(!self).leading_zeros()
|
||||
|
@ -170,6 +180,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn trailing_ones(self) -> u32 {
|
||||
(!self).trailing_zeros()
|
||||
|
@ -238,6 +250,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn swap_bytes(self) -> Self {
|
||||
intrinsics::bswap(self as $ActualT) as Self
|
||||
|
@ -259,8 +273,9 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "reverse_bits", since = "1.37.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.37.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn reverse_bits(self) -> Self {
|
||||
intrinsics::bitreverse(self as $ActualT) as Self
|
||||
}
|
||||
|
@ -349,6 +364,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn to_be(self) -> Self { // or not to be?
|
||||
#[cfg(target_endian = "big")]
|
||||
|
@ -381,6 +398,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn to_le(self) -> Self {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
@ -658,7 +677,8 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base,
|
||||
/// rounded down.
|
||||
///
|
||||
/// This method might not be optimized owing to implementation details;
|
||||
/// `log2` can produce results more efficiently for base 2, and `log10`
|
||||
|
@ -667,8 +687,7 @@ macro_rules! uint_impl {
|
|||
/// # Panics
|
||||
///
|
||||
/// When the number is negative, zero, or if the base is not at least 2;
|
||||
/// it panics in debug mode and the return value is wrapped to 0 in
|
||||
/// release mode (the only situation in which the method can return 0).
|
||||
/// it panics in debug mode and the return value is 0 in release mode.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -678,7 +697,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -696,13 +715,12 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 2 logarithm of the number.
|
||||
/// Returns the base 2 logarithm of the number, rounded down.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// When the number is negative or zero it panics in debug mode and
|
||||
/// the return value is wrapped to 0 in release mode (the only situation in
|
||||
/// which the method can return 0).
|
||||
/// the return value is 0 in release mode.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -712,7 +730,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -730,13 +748,12 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 10 logarithm of the number.
|
||||
/// Returns the base 10 logarithm of the number, rounded down.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// When the number is negative or zero it panics in debug mode and the
|
||||
/// return value is wrapped to 0 in release mode (the only situation in
|
||||
/// which the method can return 0).
|
||||
/// return value is 0 in release mode.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -746,7 +763,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
|
@ -764,7 +781,8 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||
/// Returns the logarithm of the number with respect to an arbitrary base,
|
||||
/// rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is zero, or if the base is not at least 2.
|
||||
///
|
||||
|
@ -780,7 +798,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log(self, base: Self) -> Option<u32> {
|
||||
if self <= 0 || base <= 1 {
|
||||
|
@ -804,7 +822,7 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 2 logarithm of the number.
|
||||
/// Returns the base 2 logarithm of the number, rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is zero.
|
||||
///
|
||||
|
@ -816,7 +834,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log2(self) -> Option<u32> {
|
||||
if self <= 0 {
|
||||
|
@ -828,7 +846,7 @@ macro_rules! uint_impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the base 10 logarithm of the number.
|
||||
/// Returns the base 10 logarithm of the number, rounded down.
|
||||
///
|
||||
/// Returns `None` if the number is zero.
|
||||
///
|
||||
|
@ -840,7 +858,7 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[unstable(feature = "int_log", issue = "70887")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_log10(self) -> Option<u32> {
|
||||
int_log10::$ActualT(self as $ActualT)
|
||||
|
@ -861,6 +879,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "wrapping", since = "1.7.0")]
|
||||
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_neg(self) -> Option<Self> {
|
||||
let (a, b) = self.overflowing_neg();
|
||||
|
@ -1222,7 +1242,7 @@ macro_rules! uint_impl {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn wrapping_mul(self, rhs: Self) -> Self {
|
||||
intrinsics::wrapping_mul(self, rhs)
|
||||
|
@ -1347,6 +1367,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "num_wrapping", since = "1.2.0")]
|
||||
#[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
pub const fn wrapping_neg(self) -> Self {
|
||||
(0 as $SelfT).wrapping_sub(self)
|
||||
|
@ -1602,6 +1624,8 @@ macro_rules! uint_impl {
|
|||
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(110), 10", stringify!($SelfT), ");")]
|
||||
/// ```
|
||||
#[unstable(feature = "int_abs_diff", issue = "89492")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn abs_diff(self, other: Self) -> Self {
|
||||
if mem::size_of::<Self>() == 1 {
|
||||
|
@ -1776,6 +1800,8 @@ macro_rules! uint_impl {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "wrapping", since = "1.7.0")]
|
||||
#[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn overflowing_neg(self) -> (Self, bool) {
|
||||
((!self).wrapping_add(1), self != 0)
|
||||
}
|
||||
|
@ -1892,7 +1918,7 @@ macro_rules! uint_impl {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn pow(self, mut exp: u32) -> Self {
|
||||
|
@ -1989,6 +2015,8 @@ macro_rules! uint_impl {
|
|||
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_floor(4), 1);")]
|
||||
/// ```
|
||||
#[unstable(feature = "int_roundings", issue = "88581")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
|
||||
|
@ -2010,6 +2038,8 @@ macro_rules! uint_impl {
|
|||
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_ceil(4), 2);")]
|
||||
/// ```
|
||||
#[unstable(feature = "int_roundings", issue = "88581")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
|
||||
|
@ -2087,6 +2117,7 @@ macro_rules! uint_impl {
|
|||
#[doc = concat!("assert!(16", stringify!($SelfT), ".is_power_of_two());")]
|
||||
#[doc = concat!("assert!(!10", stringify!($SelfT), ".is_power_of_two());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_is_power_of_two", since = "1.32.0")]
|
||||
#[inline(always)]
|
||||
|
@ -2120,7 +2151,7 @@ macro_rules! uint_impl {
|
|||
/// Returns the smallest power of two greater than or equal to `self`.
|
||||
///
|
||||
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
|
||||
/// `uN`), it panics in debug mode and return value is wrapped to 0 in
|
||||
/// `uN`), it panics in debug mode and the return value is wrapped to 0 in
|
||||
/// release mode (the only situation in which method can return 0).
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -2133,6 +2164,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn next_power_of_two(self) -> Self {
|
||||
|
@ -2155,6 +2188,8 @@ macro_rules! uint_impl {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn checked_next_power_of_two(self) -> Option<Self> {
|
||||
self.one_less_than_next_power_of_two().checked_add(1)
|
||||
}
|
||||
|
@ -2177,6 +2212,8 @@ macro_rules! uint_impl {
|
|||
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
|
||||
reason = "needs decision on wrapping behaviour")]
|
||||
#[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn wrapping_next_power_of_two(self) -> Self {
|
||||
self.one_less_than_next_power_of_two().wrapping_add(1)
|
||||
}
|
||||
|
@ -2194,6 +2231,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
||||
self.to_be().to_ne_bytes()
|
||||
|
@ -2212,6 +2251,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
||||
self.to_le().to_ne_bytes()
|
||||
|
@ -2244,6 +2285,8 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
// SAFETY: const sound because integers are plain old datatypes so we can always
|
||||
// transmute them to arrays of bytes
|
||||
#[inline]
|
||||
|
|
|
@ -469,6 +469,8 @@ macro_rules! wrapping_int_impl {
|
|||
#[inline]
|
||||
#[doc(alias = "popcount")]
|
||||
#[doc(alias = "popcnt")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn count_ones(self) -> u32 {
|
||||
self.0.count_ones()
|
||||
|
@ -487,6 +489,8 @@ macro_rules! wrapping_int_impl {
|
|||
#[doc = concat!("assert_eq!(Wrapping(!0", stringify!($t), ").count_zeros(), 0);")]
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn count_zeros(self) -> u32 {
|
||||
self.0.count_zeros()
|
||||
|
@ -507,6 +511,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// assert_eq!(n.trailing_zeros(), 3);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn trailing_zeros(self) -> u32 {
|
||||
self.0.trailing_zeros()
|
||||
|
@ -533,6 +539,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// assert_eq!(n.rotate_left(32), m);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn rotate_left(self, n: u32) -> Self {
|
||||
Wrapping(self.0.rotate_left(n))
|
||||
|
@ -559,6 +567,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// assert_eq!(n.rotate_right(4), m);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn rotate_right(self, n: u32) -> Self {
|
||||
Wrapping(self.0.rotate_right(n))
|
||||
|
@ -583,6 +593,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// assert_eq!(m, Wrapping(21760));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn swap_bytes(self) -> Self {
|
||||
Wrapping(self.0.swap_bytes())
|
||||
|
@ -610,8 +622,9 @@ macro_rules! wrapping_int_impl {
|
|||
/// ```
|
||||
#[stable(feature = "reverse_bits", since = "1.37.0")]
|
||||
#[rustc_const_stable(feature = "const_reverse_bits", since = "1.37.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn reverse_bits(self) -> Self {
|
||||
Wrapping(self.0.reverse_bits())
|
||||
}
|
||||
|
@ -692,6 +705,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn to_be(self) -> Self {
|
||||
Wrapping(self.0.to_be())
|
||||
|
@ -719,6 +734,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn to_le(self) -> Self {
|
||||
Wrapping(self.0.to_le())
|
||||
|
@ -747,6 +764,8 @@ macro_rules! wrapping_int_impl {
|
|||
/// assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub fn pow(self, exp: u32) -> Self {
|
||||
Wrapping(self.0.wrapping_pow(exp))
|
||||
|
@ -775,6 +794,8 @@ macro_rules! wrapping_int_impl_signed {
|
|||
/// assert_eq!(n.leading_zeros(), 3);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
self.0.leading_zeros()
|
||||
|
@ -801,6 +822,8 @@ macro_rules! wrapping_int_impl_signed {
|
|||
/// assert_eq!(Wrapping(-128i8).abs().0 as u8, 128u8);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub fn abs(self) -> Wrapping<$t> {
|
||||
Wrapping(self.0.wrapping_abs())
|
||||
|
@ -825,6 +848,8 @@ macro_rules! wrapping_int_impl_signed {
|
|||
#[doc = concat!("assert_eq!(Wrapping(-10", stringify!($t), ").signum(), Wrapping(-1));")]
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub fn signum(self) -> Wrapping<$t> {
|
||||
Wrapping(self.0.signum())
|
||||
|
@ -844,6 +869,7 @@ macro_rules! wrapping_int_impl_signed {
|
|||
#[doc = concat!("assert!(Wrapping(10", stringify!($t), ").is_positive());")]
|
||||
#[doc = concat!("assert!(!Wrapping(-10", stringify!($t), ").is_positive());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn is_positive(self) -> bool {
|
||||
|
@ -864,6 +890,7 @@ macro_rules! wrapping_int_impl_signed {
|
|||
#[doc = concat!("assert!(Wrapping(-10", stringify!($t), ").is_negative());")]
|
||||
#[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_negative());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn is_negative(self) -> bool {
|
||||
|
@ -893,6 +920,8 @@ macro_rules! wrapping_int_impl_unsigned {
|
|||
/// assert_eq!(n.leading_zeros(), 2);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn leading_zeros(self) -> u32 {
|
||||
self.0.leading_zeros()
|
||||
|
@ -911,6 +940,7 @@ macro_rules! wrapping_int_impl_unsigned {
|
|||
#[doc = concat!("assert!(Wrapping(16", stringify!($t), ").is_power_of_two());")]
|
||||
#[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_power_of_two());")]
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub fn is_power_of_two(self) -> bool {
|
||||
|
@ -935,6 +965,8 @@ macro_rules! wrapping_int_impl_unsigned {
|
|||
#[doc = concat!("assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));")]
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
|
||||
reason = "needs decision on wrapping behaviour")]
|
||||
pub fn next_power_of_two(self) -> Self {
|
||||
|
|
|
@ -188,6 +188,7 @@ impl str {
|
|||
/// // third byte of `老`
|
||||
/// assert!(!s.is_char_boundary(8));
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "is_char_boundary", since = "1.9.0")]
|
||||
#[inline]
|
||||
pub fn is_char_boundary(&self, index: usize) -> bool {
|
||||
|
|
|
@ -291,6 +291,7 @@ impl Duration {
|
|||
/// assert!(!Duration::from_nanos(1).is_zero());
|
||||
/// assert!(!Duration::from_secs(1).is_zero());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "duration_zero", since = "1.53.0")]
|
||||
#[rustc_const_stable(feature = "duration_zero", since = "1.53.0")]
|
||||
#[inline]
|
||||
|
@ -464,6 +465,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(1, 0).checked_add(Duration::new(u64::MAX, 0)), None);
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn checked_add(self, rhs: Duration) -> Option<Duration> {
|
||||
|
@ -497,6 +500,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX);
|
||||
/// ```
|
||||
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn saturating_add(self, rhs: Duration) -> Duration {
|
||||
|
@ -520,6 +525,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(0, 0).checked_sub(Duration::new(0, 1)), None);
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn checked_sub(self, rhs: Duration) -> Option<Duration> {
|
||||
|
@ -551,6 +558,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO);
|
||||
/// ```
|
||||
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn saturating_sub(self, rhs: Duration) -> Duration {
|
||||
|
@ -574,6 +583,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(u64::MAX - 1, 0).checked_mul(2), None);
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn checked_mul(self, rhs: u32) -> Option<Duration> {
|
||||
|
@ -603,6 +614,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX);
|
||||
/// ```
|
||||
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn saturating_mul(self, rhs: u32) -> Duration {
|
||||
|
@ -627,6 +640,8 @@ impl Duration {
|
|||
/// assert_eq!(Duration::new(2, 0).checked_div(0), None);
|
||||
/// ```
|
||||
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn checked_div(self, rhs: u32) -> Option<Duration> {
|
||||
|
@ -814,6 +829,8 @@ impl Duration {
|
|||
/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn mul_f64(self, rhs: f64) -> Duration {
|
||||
|
@ -836,6 +853,8 @@ impl Duration {
|
|||
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn mul_f32(self, rhs: f32) -> Duration {
|
||||
|
@ -857,6 +876,8 @@ impl Duration {
|
|||
/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn div_f64(self, rhs: f64) -> Duration {
|
||||
|
@ -880,6 +901,8 @@ impl Duration {
|
|||
/// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn div_f32(self, rhs: f32) -> Duration {
|
||||
|
@ -898,6 +921,8 @@ impl Duration {
|
|||
/// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
|
||||
/// ```
|
||||
#[unstable(feature = "div_duration", issue = "63139")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn div_duration_f64(self, rhs: Duration) -> f64 {
|
||||
|
@ -916,6 +941,8 @@ impl Duration {
|
|||
/// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
|
||||
/// ```
|
||||
#[unstable(feature = "div_duration", issue = "63139")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn div_duration_f32(self, rhs: Duration) -> f32 {
|
||||
|
|
|
@ -61,7 +61,7 @@ use std::{error, fmt, iter, mem};
|
|||
/// non-panicking way to detect whether the infrastructure required to use the
|
||||
/// API of proc_macro is presently available. Returns true if invoked from
|
||||
/// inside of a procedural macro, false if invoked from any other binary.
|
||||
#[unstable(feature = "proc_macro_is_available", issue = "71436")]
|
||||
#[stable(feature = "proc_macro_is_available", since = "1.57.0")]
|
||||
pub fn is_available() -> bool {
|
||||
bridge::Bridge::is_available()
|
||||
}
|
||||
|
|
|
@ -898,7 +898,7 @@ impl Step for RustdocGUI {
|
|||
let out_dir = builder.test_out(self.target).join("rustdoc-gui");
|
||||
|
||||
// We remove existing folder to be sure there won't be artifacts remaining.
|
||||
let _ = fs::remove_dir_all(&out_dir);
|
||||
builder.clear_if_dirty(&out_dir, &builder.rustdoc(self.compiler));
|
||||
|
||||
let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
|
||||
// We generate docs for the libraries present in the rustdoc-gui's src folder.
|
||||
|
|
|
@ -456,7 +456,7 @@ operand := reg_operand / "const" const_expr / "sym" path
|
|||
clobber_abi := "clobber_abi(" <abi> ")"
|
||||
option := "pure" / "nomem" / "readonly" / "preserves_flags" / "noreturn" / "nostack" / "att_syntax" / "raw"
|
||||
options := "options(" option *["," option] [","] ")"
|
||||
asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) ["," clobber_abi] ["," options] [","] ")"
|
||||
asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) ["," clobber_abi] *("," options) [","] ")"
|
||||
```
|
||||
|
||||
Inline assembly is currently supported on the following architectures:
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#![deny(non_exhaustive_omitted_patterns)]
|
||||
//~^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
#![allow(non_exhaustive_omitted_patterns)]
|
||||
//~^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
|
||||
fn main() {
|
||||
enum Foo {
|
||||
A, B, C,
|
||||
}
|
||||
|
||||
#[allow(non_exhaustive_omitted_patterns)]
|
||||
match Foo::A {
|
||||
Foo::A => {}
|
||||
Foo::B => {}
|
||||
}
|
||||
//~^^^^^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
|
||||
match Foo::A {
|
||||
Foo::A => {}
|
||||
Foo::B => {}
|
||||
#[warn(non_exhaustive_omitted_patterns)]
|
||||
_ => {}
|
||||
}
|
||||
//~^^^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:1:1
|
||||
|
|
||||
LL | #![deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:4:1
|
||||
|
|
||||
LL | #![allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
||||
|
|
||||
LL | #[allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
||||
|
|
||||
LL | #[allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:26:9
|
||||
|
|
||||
LL | #[warn(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:1:1
|
||||
|
|
||||
LL | #![deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:4:1
|
||||
|
|
||||
LL | #![allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
||||
|
|
||||
LL | #[allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
||||
|
|
||||
LL | #[allow(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
|
||||
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:26:9
|
||||
|
|
||||
LL | #[warn(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
|
||||
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
|
@ -2,7 +2,6 @@
|
|||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(proc_macro_is_available)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(proc_macro_is_available)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
// aux-build:is-available.rs
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly.
|
||||
|
||||
#![feature(non_exhaustive_omitted_patterns_lint)]
|
||||
|
||||
// aux-build:enums.rs
|
||||
extern crate enums;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
warning: some fields are not explicitly listed
|
||||
--> $DIR/reachable-patterns.rs:127:9
|
||||
--> $DIR/reachable-patterns.rs:129:9
|
||||
|
|
||||
LL | VariantNonExhaustive::Bar { x, .. } => {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:124:12
|
||||
--> $DIR/reachable-patterns.rs:126:12
|
||||
|
|
||||
LL | #[warn(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -13,13 +13,13 @@ LL | #[warn(non_exhaustive_omitted_patterns)]
|
|||
= note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
warning: some fields are not explicitly listed
|
||||
--> $DIR/reachable-patterns.rs:132:9
|
||||
--> $DIR/reachable-patterns.rs:134:9
|
||||
|
|
||||
LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:131:12
|
||||
--> $DIR/reachable-patterns.rs:133:12
|
||||
|
|
||||
LL | #[warn(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -27,13 +27,13 @@ LL | #[warn(non_exhaustive_omitted_patterns)]
|
|||
= note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
warning: some fields are not explicitly listed
|
||||
--> $DIR/reachable-patterns.rs:140:29
|
||||
--> $DIR/reachable-patterns.rs:142:29
|
||||
|
|
||||
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:139:12
|
||||
--> $DIR/reachable-patterns.rs:141:12
|
||||
|
|
||||
LL | #[warn(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -41,7 +41,7 @@ LL | #[warn(non_exhaustive_omitted_patterns)]
|
|||
= note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
warning: some fields are not explicitly listed
|
||||
--> $DIR/reachable-patterns.rs:140:9
|
||||
--> $DIR/reachable-patterns.rs:142:9
|
||||
|
|
||||
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed
|
||||
|
@ -50,13 +50,13 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested
|
|||
= note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:54:9
|
||||
--> $DIR/reachable-patterns.rs:56:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ pattern `Struct { .. }` not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:53:16
|
||||
--> $DIR/reachable-patterns.rs:55:16
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -64,13 +64,13 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:61:9
|
||||
--> $DIR/reachable-patterns.rs:63:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ pattern `Tuple(_)` not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:60:16
|
||||
--> $DIR/reachable-patterns.rs:62:16
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -78,13 +78,13 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:71:9
|
||||
--> $DIR/reachable-patterns.rs:73:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ pattern `Unit` not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:70:16
|
||||
--> $DIR/reachable-patterns.rs:72:16
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -92,13 +92,13 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:88:32
|
||||
--> $DIR/reachable-patterns.rs:90:32
|
||||
|
|
||||
LL | NestedNonExhaustive::A(_) => {}
|
||||
| ^ patterns `Tuple(_)` and `Struct { .. }` not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:85:12
|
||||
--> $DIR/reachable-patterns.rs:87:12
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -106,7 +106,7 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:90:9
|
||||
--> $DIR/reachable-patterns.rs:92:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ pattern `C` not covered
|
||||
|
@ -115,13 +115,13 @@ LL | _ => {}
|
|||
= note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:120:9
|
||||
--> $DIR/reachable-patterns.rs:122:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ patterns `HostUnreachable`, `NetworkUnreachable`, `NetworkDown` and 18 more not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:97:12
|
||||
--> $DIR/reachable-patterns.rs:99:12
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -129,13 +129,13 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||
= note: the matched value is of type `ErrorKind` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||
|
||||
error: some variants are not matched explicitly
|
||||
--> $DIR/reachable-patterns.rs:157:9
|
||||
--> $DIR/reachable-patterns.rs:159:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ pattern `A(_)` not covered
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reachable-patterns.rs:155:12
|
||||
--> $DIR/reachable-patterns.rs:157:12
|
||||
|
|
||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
Loading…
Reference in a new issue