1
Fork 0

Auto merge of #79150 - m-ou-se:bye-bye-doc-comment-hack, r=jyn514

Remove all doc_comment!{} hacks by using #[doc = expr] where needed.

This replaces about 200 cases of

`````rust
        doc_comment! {
            concat!("The smallest value that can be represented by this integer type.

# Examples

Basic usage:

```
", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");",
$EndFeature, "
```"),
            #[stable(feature = "assoc_int_consts", since = "1.43.0")]
            pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
        }
`````
by
```rust
        /// The smallest value that can be represented by this integer type.
        ///
        /// # Examples
        ///
        /// Basic usage:
        ///
        /// ```
        #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");")]
        /// ```
        #[stable(feature = "assoc_int_consts", since = "1.43.0")]
        pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
```

---

**Note:** For a usable diff, make sure to enable 'ignore whitspace': https://github.com/rust-lang/rust/pull/79150/files?diff=unified&w=1
This commit is contained in:
bors 2020-12-31 06:14:41 +00:00
commit 8b002d5c34
8 changed files with 4596 additions and 5097 deletions

View file

@ -113,6 +113,7 @@
#![feature(doc_spotlight)] #![feature(doc_spotlight)]
#![feature(duration_consts_2)] #![feature(duration_consts_2)]
#![feature(duration_saturating_ops)] #![feature(duration_saturating_ops)]
#![feature(extended_key_value_attributes)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(fundamental)] #![feature(fundamental)]
#![feature(intrinsics)] #![feature(intrinsics)]

File diff suppressed because it is too large Load diff

View file

@ -23,13 +23,6 @@ macro_rules! unlikely {
}; };
} }
macro_rules! doc_comment {
($x:expr, $($tt:tt)*) => {
#[doc = $x]
$($tt)*
};
}
// All these modules are technically private and only exposed for coretests: // All these modules are technically private and only exposed for coretests:
pub mod bignum; pub mod bignum;
pub mod dec2flt; pub mod dec2flt;
@ -95,26 +88,26 @@ depending on the target pointer size.
#[lang = "i8"] #[lang = "i8"]
impl i8 { impl i8 {
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48", int_impl! { i8, i8, u8, 8, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
"[0x12]", "[0x12]", "", "" } "[0x12]", "[0x12]", "", "" }
} }
#[lang = "i16"] #[lang = "i16"]
impl i16 { impl i16 {
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234", "0x3412", int_impl! { i16, i16, u16, 16, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" } "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
} }
#[lang = "i32"] #[lang = "i32"]
impl i32 { impl i32 {
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301", int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]", "", "" } "[0x12, 0x34, 0x56, 0x78]", "", "" }
} }
#[lang = "i64"] #[lang = "i64"]
impl i64 { impl i64 {
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12, int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, 12,
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" } "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" }
@ -123,7 +116,7 @@ impl i64 {
#[lang = "i128"] #[lang = "i128"]
impl i128 { impl i128 {
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
170141183460469231731687303715884105727, "", "", 16, 170141183460469231731687303715884105727, 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48",
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
@ -135,7 +128,7 @@ impl i128 {
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]
#[lang = "isize"] #[lang = "isize"]
impl isize { impl isize {
int_impl! { isize, i16, usize, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234", int_impl! { isize, i16, usize, 16, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
} }
@ -143,7 +136,7 @@ impl isize {
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]
#[lang = "isize"] #[lang = "isize"]
impl isize { impl isize {
int_impl! { isize, i32, usize, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301", int_impl! { isize, i32, usize, 32, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]", "[0x12, 0x34, 0x56, 0x78]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@ -152,7 +145,7 @@ impl isize {
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
#[lang = "isize"] #[lang = "isize"]
impl isize { impl isize {
int_impl! { isize, i64, usize, 64, -9223372036854775808, 9223372036854775807, "", "", int_impl! { isize, i64, usize, 64, -9223372036854775808, 9223372036854775807,
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
@ -161,7 +154,7 @@ impl isize {
#[lang = "u8"] #[lang = "u8"]
impl u8 { impl u8 {
uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]", uint_impl! { u8, u8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
"[0x12]", "", "" } "[0x12]", "", "" }
/// Checks if the value is within the ASCII range. /// Checks if the value is within the ASCII range.
@ -660,19 +653,19 @@ impl u8 {
#[lang = "u16"] #[lang = "u16"]
impl u16 { impl u16 {
uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48", uint_impl! { u16, u16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]", "", "" } "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
} }
#[lang = "u32"] #[lang = "u32"]
impl u32 { impl u32 {
uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678", uint_impl! { u32, u32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" } "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
} }
#[lang = "u64"] #[lang = "u64"]
impl u64 { impl u64 {
uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa", uint_impl! { u64, u64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",
@ -681,7 +674,7 @@ impl u64 {
#[lang = "u128"] #[lang = "u128"]
impl u128 { impl u128 {
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
"0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48",
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
@ -694,14 +687,14 @@ impl u128 {
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]
#[lang = "usize"] #[lang = "usize"]
impl usize { impl usize {
uint_impl! { usize, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48", uint_impl! { usize, u16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]", "[0x34, 0x12]", "[0x12, 0x34]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
} }
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]
#[lang = "usize"] #[lang = "usize"]
impl usize { impl usize {
uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678", uint_impl! { usize, u32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
} }
@ -709,7 +702,7 @@ impl usize {
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
#[lang = "usize"] #[lang = "usize"]
impl usize { impl usize {
uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa", uint_impl! { usize, u64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]",

View file

@ -8,13 +8,6 @@ use super::from_str_radix;
use super::{IntErrorKind, ParseIntError}; use super::{IntErrorKind, ParseIntError};
use crate::intrinsics; use crate::intrinsics;
macro_rules! doc_comment {
($x:expr, $($tt:tt)*) => {
#[doc = $x]
$($tt)*
};
}
macro_rules! impl_nonzero_fmt { macro_rules! impl_nonzero_fmt {
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => { ( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
$( $(
@ -32,24 +25,21 @@ macro_rules! impl_nonzero_fmt {
macro_rules! nonzero_integers { macro_rules! nonzero_integers {
( $( #[$stability: meta] $Ty: ident($Int: ty); )+ ) => { ( $( #[$stability: meta] $Ty: ident($Int: ty); )+ ) => {
$( $(
doc_comment! { /// An integer that is known not to equal zero.
concat!("An integer that is known not to equal zero. ///
/// This enables some memory layout optimization.
This enables some memory layout optimization. #[doc = concat!("For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:")]
For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`: ///
/// ```rust
```rust /// use std::mem::size_of;
use std::mem::size_of; #[doc = concat!("assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int), ">());")]
assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", stringify!($Int), /// ```
">()); #[$stability]
```"), #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[$stability] #[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[rustc_layout_scalar_valid_range_start(1)]
#[repr(transparent)] #[rustc_nonnull_optimization_guaranteed]
#[rustc_layout_scalar_valid_range_start(1)] pub struct $Ty($Int);
#[rustc_nonnull_optimization_guaranteed]
pub struct $Ty($Int);
}
impl $Ty { impl $Ty {
/// Creates a non-zero without checking the value. /// Creates a non-zero without checking the value.
@ -90,13 +80,10 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
#[stable(feature = "from_nonzero", since = "1.31.0")] #[stable(feature = "from_nonzero", since = "1.31.0")]
impl From<$Ty> for $Int { impl From<$Ty> for $Int {
doc_comment! { #[doc = concat!("Converts a `", stringify!($Ty), "` into an `", stringify!($Int), "`")]
concat!( #[inline]
"Converts a `", stringify!($Ty), "` into an `", stringify!($Int), "`"), fn from(nonzero: $Ty) -> Self {
#[inline] nonzero.0
fn from(nonzero: $Ty) -> Self {
nonzero.0
}
} }
} }
@ -195,53 +182,49 @@ macro_rules! nonzero_leading_trailing_zeros {
( $( $Ty: ident($Uint: ty) , $LeadingTestExpr:expr ;)+ ) => { ( $( $Ty: ident($Uint: ty) , $LeadingTestExpr:expr ;)+ ) => {
$( $(
impl $Ty { impl $Ty {
doc_comment! { /// Returns the number of leading zeros in the binary representation of `self`.
concat!("Returns the number of leading zeros in the binary representation of `self`. ///
/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided.
On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(nonzero_leading_trailing_zeros)]
#![feature(nonzero_leading_trailing_zeros)] #[doc = concat!("let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap();")]
let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap(); ///
/// assert_eq!(n.leading_zeros(), 0);
assert_eq!(n.leading_zeros(), 0); /// ```
```"), #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] #[inline]
#[inline] pub const fn leading_zeros(self) -> u32 {
pub const fn leading_zeros(self) -> u32 { // SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero
// SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero unsafe { intrinsics::ctlz_nonzero(self.0 as $Uint) as u32 }
unsafe { intrinsics::ctlz_nonzero(self.0 as $Uint) as u32 }
}
} }
doc_comment! { /// Returns the number of trailing zeros in the binary representation
concat!("Returns the number of trailing zeros in the binary representation /// of `self`.
of `self`. ///
/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided.
On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(nonzero_leading_trailing_zeros)]
#![feature(nonzero_leading_trailing_zeros)] #[doc = concat!("let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap();")]
let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap(); ///
/// assert_eq!(n.trailing_zeros(), 3);
assert_eq!(n.trailing_zeros(), 3); /// ```
```"), #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
#[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")]
#[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] #[inline]
#[inline] pub const fn trailing_zeros(self) -> u32 {
pub const fn trailing_zeros(self) -> u32 { // SAFETY: since `self` can not be zero it is safe to call cttz_nonzero
// SAFETY: since `self` can not be zero it is safe to call cttz_nonzero unsafe { intrinsics::cttz_nonzero(self.0 as $Uint) as u32 }
unsafe { intrinsics::cttz_nonzero(self.0 as $Uint) as u32 }
}
} }
} }

View file

@ -1,49 +1,44 @@
#![doc(hidden)] #![doc(hidden)]
macro_rules! doc_comment {
($x:expr, $($tt:tt)*) => {
#[doc = $x]
$($tt)*
};
}
macro_rules! int_module { macro_rules! int_module {
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]);); ($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
($T:ident, #[$attr:meta]) => ( ($T:ident, #[$attr:meta]) => (
doc_comment! { #[doc = concat!(
concat!("The smallest value that can be represented by this integer type. "The smallest value that can be represented by this integer type. Use ",
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead. "[`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN)",
" instead.",
)]
///
/// # Examples
///
/// ```rust
/// // deprecated way
#[doc = concat!("let min = std::", stringify!($T), "::MIN;")]
///
/// // intended way
#[doc = concat!("let min = ", stringify!($T), "::MIN;")]
/// ```
///
#[$attr]
pub const MIN: $T = $T::MIN;
# Examples #[doc = concat!(
"The largest value that can be represented by this integer type. Use ",
```rust "[`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX)",
// deprecated way " instead.",
let min = std::", stringify!($T), "::MIN; )]
///
// intended way /// # Examples
let min = ", stringify!($T), "::MIN; ///
``` /// ```rust
"), /// // deprecated way
#[$attr] #[doc = concat!("let max = std::", stringify!($T), "::MAX;")]
pub const MIN: $T = $T::MIN; ///
} /// // intended way
#[doc = concat!("let max = ", stringify!($T), "::MAX;")]
doc_comment! { /// ```
concat!("The largest value that can be represented by this integer type. ///
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead. #[$attr]
pub const MAX: $T = $T::MAX;
# Examples
```rust
// deprecated way
let max = std::", stringify!($T), "::MAX;
// intended way
let max = ", stringify!($T), "::MAX;
```
"),
#[$attr]
pub const MAX: $T = $T::MAX;
}
) )
} }

File diff suppressed because it is too large Load diff

View file

@ -403,105 +403,94 @@ wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
macro_rules! wrapping_int_impl { macro_rules! wrapping_int_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
impl Wrapping<$t> { impl Wrapping<$t> {
doc_comment! { /// Returns the smallest value that can be represented by this integer type.
concat!("Returns the smallest value that can be represented by this integer type. ///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(wrapping_int_impl)]
/// use std::num::Wrapping;
///
#[doc = concat!("assert_eq!(<Wrapping<", stringify!($t), ">>::MIN, Wrapping(", stringify!($t), "::MIN));")]
/// ```
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const MIN: Self = Self(<$t>::MIN);
# Examples /// Returns the largest value that can be represented by this integer type.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(wrapping_int_impl)]
/// use std::num::Wrapping;
///
#[doc = concat!("assert_eq!(<Wrapping<", stringify!($t), ">>::MAX, Wrapping(", stringify!($t), "::MAX));")]
/// ```
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const MAX: Self = Self(<$t>::MAX);
Basic usage: /// Returns the number of ones in the binary representation of `self`.
///
``` /// # Examples
#![feature(wrapping_int_impl)] ///
use std::num::Wrapping; /// Basic usage:
///
assert_eq!(<Wrapping<", stringify!($t), ">>::MIN, Wrapping(", stringify!($t), "::MIN)); /// ```
```"), /// #![feature(wrapping_int_impl)]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] /// use std::num::Wrapping;
pub const MIN: Self = Self(<$t>::MIN); ///
#[doc = concat!("let n = Wrapping(0b01001100", stringify!($t), ");")]
///
/// assert_eq!(n.count_ones(), 3);
/// ```
#[inline]
#[doc(alias = "popcount")]
#[doc(alias = "popcnt")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn count_ones(self) -> u32 {
self.0.count_ones()
} }
doc_comment! { /// Returns the number of zeros in the binary representation of `self`.
concat!("Returns the largest value that can be represented by this integer type. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert_eq!(Wrapping(!0", stringify!($t), ").count_zeros(), 0);")]
assert_eq!(<Wrapping<", stringify!($t), ">>::MAX, Wrapping(", stringify!($t), "::MAX)); /// ```
```"), #[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const MAX: Self = Self(<$t>::MAX); pub const fn count_zeros(self) -> u32 {
self.0.count_zeros()
} }
doc_comment! { /// Returns the number of trailing zeros in the binary representation of `self`.
concat!("Returns the number of ones in the binary representation of `self`. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(0b0101000", stringify!($t), ");")]
let n = Wrapping(0b01001100", stringify!($t), "); ///
/// assert_eq!(n.trailing_zeros(), 3);
assert_eq!(n.count_ones(), 3); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[doc(alias = "popcount")] pub const fn trailing_zeros(self) -> u32 {
#[doc(alias = "popcnt")] self.0.trailing_zeros()
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn count_ones(self) -> u32 {
self.0.count_ones()
}
}
doc_comment! {
concat!("Returns the number of zeros in the binary representation of `self`.
# Examples
Basic usage:
```
#![feature(wrapping_int_impl)]
use std::num::Wrapping;
assert_eq!(Wrapping(!0", stringify!($t), ").count_zeros(), 0);
```"),
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn count_zeros(self) -> u32 {
self.0.count_zeros()
}
}
doc_comment! {
concat!("Returns the number of trailing zeros in the binary representation
of `self`.
# Examples
Basic usage:
```
#![feature(wrapping_int_impl)]
use std::num::Wrapping;
let n = Wrapping(0b0101000", stringify!($t), ");
assert_eq!(n.trailing_zeros(), 3);
```"),
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn trailing_zeros(self) -> u32 {
self.0.trailing_zeros()
}
} }
/// Shifts the bits to the left by a specified amount, `n`, /// Shifts the bits to the left by a specified amount, `n`,
@ -608,150 +597,140 @@ assert_eq!(n.trailing_zeros(), 3);
Wrapping(self.0.reverse_bits()) Wrapping(self.0.reverse_bits())
} }
doc_comment! { /// Converts an integer from big endian to the target's endianness.
concat!("Converts an integer from big endian to the target's endianness. ///
/// On big endian this is a no-op. On little endian the bytes are
On big endian this is a no-op. On little endian the bytes are /// swapped.
swapped. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(0x1A", stringify!($t), ");")]
let n = Wrapping(0x1A", stringify!($t), "); ///
/// if cfg!(target_endian = "big") {
if cfg!(target_endian = \"big\") { #[doc = concat!(" assert_eq!(<Wrapping<", stringify!($t), ">>::from_be(n), n)")]
assert_eq!(<Wrapping<", stringify!($t), ">>::from_be(n), n) /// } else {
} else { #[doc = concat!(" assert_eq!(<Wrapping<", stringify!($t), ">>::from_be(n), n.swap_bytes())")]
assert_eq!(<Wrapping<", stringify!($t), ">>::from_be(n), n.swap_bytes()) /// }
} /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn from_be(x: Self) -> Self {
pub const fn from_be(x: Self) -> Self { Wrapping(<$t>::from_be(x.0))
Wrapping(<$t>::from_be(x.0))
}
} }
doc_comment! { /// Converts an integer from little endian to the target's endianness.
concat!("Converts an integer from little endian to the target's endianness. ///
/// On little endian this is a no-op. On big endian the bytes are
On little endian this is a no-op. On big endian the bytes are /// swapped.
swapped. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(0x1A", stringify!($t), ");")]
let n = Wrapping(0x1A", stringify!($t), "); ///
/// if cfg!(target_endian = "little") {
if cfg!(target_endian = \"little\") { #[doc = concat!(" assert_eq!(<Wrapping<", stringify!($t), ">>::from_le(n), n)")]
assert_eq!(<Wrapping<", stringify!($t), ">>::from_le(n), n) /// } else {
} else { #[doc = concat!(" assert_eq!(<Wrapping<", stringify!($t), ">>::from_le(n), n.swap_bytes())")]
assert_eq!(<Wrapping<", stringify!($t), ">>::from_le(n), n.swap_bytes()) /// }
} /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn from_le(x: Self) -> Self {
pub const fn from_le(x: Self) -> Self { Wrapping(<$t>::from_le(x.0))
Wrapping(<$t>::from_le(x.0))
}
} }
doc_comment! { /// Converts `self` to big endian from the target's endianness.
concat!("Converts `self` to big endian from the target's endianness. ///
/// On big endian this is a no-op. On little endian the bytes are
On big endian this is a no-op. On little endian the bytes are /// swapped.
swapped. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(0x1A", stringify!($t), ");")]
let n = Wrapping(0x1A", stringify!($t), "); ///
/// if cfg!(target_endian = "big") {
if cfg!(target_endian = \"big\") { /// assert_eq!(n.to_be(), n)
assert_eq!(n.to_be(), n) /// } else {
} else { /// assert_eq!(n.to_be(), n.swap_bytes())
assert_eq!(n.to_be(), n.swap_bytes()) /// }
} /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn to_be(self) -> Self {
pub const fn to_be(self) -> Self { Wrapping(self.0.to_be())
Wrapping(self.0.to_be())
}
} }
doc_comment! { /// Converts `self` to little endian from the target's endianness.
concat!("Converts `self` to little endian from the target's endianness. ///
/// On little endian this is a no-op. On big endian the bytes are
On little endian this is a no-op. On big endian the bytes are /// swapped.
swapped. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(0x1A", stringify!($t), ");")]
let n = Wrapping(0x1A", stringify!($t), "); ///
/// if cfg!(target_endian = "little") {
if cfg!(target_endian = \"little\") { /// assert_eq!(n.to_le(), n)
assert_eq!(n.to_le(), n) /// } else {
} else { /// assert_eq!(n.to_le(), n.swap_bytes())
assert_eq!(n.to_le(), n.swap_bytes()) /// }
} /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn to_le(self) -> Self {
pub const fn to_le(self) -> Self { Wrapping(self.0.to_le())
Wrapping(self.0.to_le())
}
} }
doc_comment! { /// Raises self to the power of `exp`, using exponentiation by squaring.
concat!("Raises self to the power of `exp`, using exponentiation by squaring. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert_eq!(Wrapping(3", stringify!($t), ").pow(4), Wrapping(81));")]
assert_eq!(Wrapping(3", stringify!($t), ").pow(4), Wrapping(81)); /// ```
``` ///
/// Results that are too large are wrapped:
Results that are too large are wrapped: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
/// assert_eq!(Wrapping(3i8).pow(5), Wrapping(-13));
assert_eq!(Wrapping(3i8).pow(5), Wrapping(-13)); /// assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39));
assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub fn pow(self, exp: u32) -> Self {
pub fn pow(self, exp: u32) -> Self { Wrapping(self.0.wrapping_pow(exp))
Wrapping(self.0.wrapping_pow(exp))
}
} }
} }
)*) )*)
@ -762,124 +741,114 @@ wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
macro_rules! wrapping_int_impl_signed { macro_rules! wrapping_int_impl_signed {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
impl Wrapping<$t> { impl Wrapping<$t> {
doc_comment! { /// Returns the number of leading zeros in the binary representation of `self`.
concat!("Returns the number of leading zeros in the binary representation of `self`. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(", stringify!($t), "::MAX) >> 2;")]
let n = Wrapping(", stringify!($t), "::MAX) >> 2; ///
/// assert_eq!(n.leading_zeros(), 3);
assert_eq!(n.leading_zeros(), 3); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn leading_zeros(self) -> u32 {
pub const fn leading_zeros(self) -> u32 { self.0.leading_zeros()
self.0.leading_zeros()
}
} }
doc_comment! { /// Computes the absolute value of `self`, wrapping around at
concat!("Computes the absolute value of `self`, wrapping around at /// the boundary of the type.
the boundary of the type. ///
/// The only case where such wrapping can occur is when one takes the absolute value of the negative
The only case where such wrapping can occur is when one takes the absolute value of the negative /// minimal value for the type this is a positive value that is too large to represent in the type. In
minimal value for the type this is a positive value that is too large to represent in the type. In /// such a case, this function returns `MIN` itself.
such a case, this function returns `MIN` itself. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert_eq!(Wrapping(100", stringify!($t), ").abs(), Wrapping(100));")]
assert_eq!(Wrapping(100", stringify!($t), ").abs(), Wrapping(100)); #[doc = concat!("assert_eq!(Wrapping(-100", stringify!($t), ").abs(), Wrapping(100));")]
assert_eq!(Wrapping(-100", stringify!($t), ").abs(), Wrapping(100)); #[doc = concat!("assert_eq!(Wrapping(", stringify!($t), "::MIN).abs(), Wrapping(", stringify!($t), "::MIN));")]
assert_eq!(Wrapping(", stringify!($t), "::MIN).abs(), Wrapping(", stringify!($t), "::MIN)); /// assert_eq!(Wrapping(-128i8).abs().0 as u8, 128u8);
assert_eq!(Wrapping(-128i8).abs().0 as u8, 128u8); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub fn abs(self) -> Wrapping<$t> {
pub fn abs(self) -> Wrapping<$t> { Wrapping(self.0.wrapping_abs())
Wrapping(self.0.wrapping_abs())
}
} }
doc_comment! { /// Returns a number representing sign of `self`.
concat!("Returns a number representing sign of `self`. ///
/// - `0` if the number is zero
- `0` if the number is zero /// - `1` if the number is positive
- `1` if the number is positive /// - `-1` if the number is negative
- `-1` if the number is negative ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert_eq!(Wrapping(10", stringify!($t), ").signum(), Wrapping(1));")]
assert_eq!(Wrapping(10", stringify!($t), ").signum(), Wrapping(1)); #[doc = concat!("assert_eq!(Wrapping(0", stringify!($t), ").signum(), Wrapping(0));")]
assert_eq!(Wrapping(0", stringify!($t), ").signum(), Wrapping(0)); #[doc = concat!("assert_eq!(Wrapping(-10", stringify!($t), ").signum(), Wrapping(-1));")]
assert_eq!(Wrapping(-10", stringify!($t), ").signum(), Wrapping(-1)); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub fn signum(self) -> Wrapping<$t> {
pub fn signum(self) -> Wrapping<$t> { Wrapping(self.0.signum())
Wrapping(self.0.signum())
}
} }
doc_comment! { /// Returns `true` if `self` is positive and `false` if the number is zero or
concat!("Returns `true` if `self` is positive and `false` if the number is zero or /// negative.
negative. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert!(Wrapping(10", stringify!($t), ").is_positive());")]
assert!(Wrapping(10", stringify!($t), ").is_positive()); #[doc = concat!("assert!(!Wrapping(-10", stringify!($t), ").is_positive());")]
assert!(!Wrapping(-10", stringify!($t), ").is_positive()); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn is_positive(self) -> bool {
pub const fn is_positive(self) -> bool { self.0.is_positive()
self.0.is_positive()
}
} }
doc_comment! { /// Returns `true` if `self` is negative and `false` if the number is zero or
concat!("Returns `true` if `self` is negative and `false` if the number is zero or /// positive.
positive. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert!(Wrapping(-10", stringify!($t), ").is_negative());")]
assert!(Wrapping(-10", stringify!($t), ").is_negative()); #[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_negative());")]
assert!(!Wrapping(10", stringify!($t), ").is_negative()); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn is_negative(self) -> bool {
pub const fn is_negative(self) -> bool { self.0.is_negative()
self.0.is_negative()
}
} }
} }
)*) )*)
@ -890,73 +859,67 @@ wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 }
macro_rules! wrapping_int_impl_unsigned { macro_rules! wrapping_int_impl_unsigned {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
impl Wrapping<$t> { impl Wrapping<$t> {
doc_comment! { /// Returns the number of leading zeros in the binary representation of `self`.
concat!("Returns the number of leading zeros in the binary representation of `self`. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("let n = Wrapping(", stringify!($t), "::MAX) >> 2;")]
let n = Wrapping(", stringify!($t), "::MAX) >> 2; ///
/// assert_eq!(n.leading_zeros(), 2);
assert_eq!(n.leading_zeros(), 2); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub const fn leading_zeros(self) -> u32 {
pub const fn leading_zeros(self) -> u32 { self.0.leading_zeros()
self.0.leading_zeros()
}
} }
doc_comment! { /// Returns `true` if and only if `self == 2^k` for some `k`.
concat!("Returns `true` if and only if `self == 2^k` for some `k`. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_int_impl)]
#![feature(wrapping_int_impl)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert!(Wrapping(16", stringify!($t), ").is_power_of_two());")]
assert!(Wrapping(16", stringify!($t), ").is_power_of_two()); #[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_power_of_two());")]
assert!(!Wrapping(10", stringify!($t), ").is_power_of_two()); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_int_impl", issue = "32463")] pub fn is_power_of_two(self) -> bool {
pub fn is_power_of_two(self) -> bool { self.0.is_power_of_two()
self.0.is_power_of_two()
}
} }
doc_comment! { /// Returns the smallest power of two greater than or equal to `self`.
concat!("Returns the smallest power of two greater than or equal to `self`. ///
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
When return value overflows (i.e., `self > (1 << (N-1))` for type /// `uN`), overflows to `2^N = 0`.
`uN`), overflows to `2^N = 0`. ///
/// # Examples
# Examples ///
/// Basic usage:
Basic usage: ///
/// ```
``` /// #![feature(wrapping_next_power_of_two)]
#![feature(wrapping_next_power_of_two)] /// use std::num::Wrapping;
use std::num::Wrapping; ///
#[doc = concat!("assert_eq!(Wrapping(2", stringify!($t), ").next_power_of_two(), Wrapping(2));")]
assert_eq!(Wrapping(2", stringify!($t), ").next_power_of_two(), Wrapping(2)); #[doc = concat!("assert_eq!(Wrapping(3", stringify!($t), ").next_power_of_two(), Wrapping(4));")]
assert_eq!(Wrapping(3", stringify!($t), ").next_power_of_two(), Wrapping(4)); #[doc = concat!("assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));")]
assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); /// ```
```"), #[inline]
#[inline] #[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463", reason = "needs decision on wrapping behaviour")]
reason = "needs decision on wrapping behaviour")] pub fn next_power_of_two(self) -> Self {
pub fn next_power_of_two(self) -> Self { Wrapping(self.0.wrapping_next_power_of_two())
Wrapping(self.0.wrapping_next_power_of_two())
}
} }
} }
)*) )*)

File diff suppressed because it is too large Load diff