Skip to content

Commit

Permalink
Auto merge of #53216 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 15 pull requests

Successful merges:

 - #52773 (Avoid unnecessary pattern matching against Option and Result)
 - #53082 (Fix doc link (again))
 - #53094 (Automatically expand section if url id point to one of its component)
 - #53106 (atomic ordering docs)
 - #53110 (Account for --remap-path-prefix in save-analysis)
 - #53116 (NetBSD: fix signedess of char)
 - #53179 (Whitelist wasm32 simd128 target feature)
 - #53183 (Suggest comma when missing in macro call)
 - #53207 (Add individual docs for rotate_{left, right})
 - #53211 ([nll] enable feature(nll) on various crates for bootstrap)
 - #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2)
 - #53215 (Slightly refactor syntax_ext/format)
 - #53217 (inline some short functions)
 - #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3)
 - #53222 (A few cleanups for rustc_target)
  • Loading branch information
bors committed Aug 9, 2018
2 parents b73535f + 9f55705 commit 8958ed6
Show file tree
Hide file tree
Showing 98 changed files with 791 additions and 409 deletions.
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

#![cfg_attr(not(test), feature(fn_traits))]
#![cfg_attr(not(test), feature(generator_trait))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(test, feature(test))]

#![feature(allocator_api)]
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_jemalloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#![feature(core_intrinsics)]
#![feature(libc)]
#![feature(linkage)]
#![cfg_attr(not(stage0), feature(nll))]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))]
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "32838")]

#![feature(allocator_api)]
#![feature(core_intrinsics)]
#![cfg_attr(not(stage0), feature(nll))]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]
Expand Down
1 change: 1 addition & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![cfg_attr(not(stage0), feature(nll))]
#![feature(raw_vec_internals)]
#![cfg_attr(test, feature(test))]

Expand Down
2 changes: 2 additions & 0 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert_eq!(2, 2.max(2));
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
fn max(self, other: Self) -> Self
where Self: Sized {
if other >= self { other } else { self }
Expand All @@ -485,6 +486,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert_eq!(2, 2.min(2));
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
fn min(self, other: Self) -> Self
where Self: Sized {
if self <= other { self } else { other }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<T: ?Sized> !Send for *mut T { }
message="the size for values of type `{Self}` cannot be known at compilation time",
label="doesn't have a size known at compile-time",
note="to learn more, visit <https://doc.rust-lang.org/book/second-edition/\
ch19-04-advanced-types.html#dynamically-sized-types-and-sized>",
ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>",
)]
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
pub trait Sized {
Expand Down
228 changes: 115 additions & 113 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mod wrapping;
// `Int` + `SignedInt` implemented for signed integers
macro_rules! int_impl {
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr, $Feature:expr,
$EndFeature:expr) => {
$EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
Expand Down Expand Up @@ -334,55 +334,52 @@ $EndFeature, "
}
}

/// Shifts the bits to the left by a specified amount, `n`,
/// wrapping the truncated bits to the end of the resulting integer.
///
/// Please note this isn't the same operation as `<<`!
///
/// # Examples
///
/// Please note that this example is shared between integer types.
/// Which explains why `i64` is used here.
///
/// Basic usage:
///
/// ```
/// let n = 0x0123456789ABCDEFi64;
/// let m = -0x76543210FEDCBA99i64;
///
/// assert_eq!(n.rotate_left(32), m);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_left(self, n: u32) -> Self {
(self as $UnsignedT).rotate_left(n) as Self
}
doc_comment! {
concat!("Shifts the bits to the left by a specified amount, `n`,
wrapping the truncated bits to the end of the resulting integer.
/// Shifts the bits to the right by a specified amount, `n`,
/// wrapping the truncated bits to the beginning of the resulting
/// integer.
///
/// Please note this isn't the same operation as `>>`!
///
/// # Examples
///
/// Please note that this example is shared between integer types.
/// Which explains why `i64` is used here.
///
/// Basic usage:
///
/// ```
/// let n = 0x0123456789ABCDEFi64;
/// let m = -0xFEDCBA987654322i64;
///
/// assert_eq!(n.rotate_right(4), m);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_right(self, n: u32) -> Self {
(self as $UnsignedT).rotate_right(n) as Self
Please note this isn't the same operation as `<<`!
# Examples
Basic usage:
```
let n = ", $rot_op, stringify!($SelfT), ";
let m = ", $rot_result, ";
assert_eq!(n.rotate_left(", $rot, "), m);
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_left(self, n: u32) -> Self {
(self as $UnsignedT).rotate_left(n) as Self
}
}

doc_comment! {
concat!("Shifts the bits to the right by a specified amount, `n`,
wrapping the truncated bits to the beginning of the resulting
integer.
Please note this isn't the same operation as `>>`!
# Examples
Basic usage:
```
let n = ", $rot_result, stringify!($SelfT), ";
let m = ", $rot_op, ";
assert_eq!(n.rotate_right(", $rot, "), m);
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_right(self, n: u32) -> Self {
(self as $UnsignedT).rotate_right(n) as Self
}
}
/// Reverses the byte order of the integer.
///
/// # Examples
Expand Down Expand Up @@ -2012,46 +2009,50 @@ $EndFeature, "

#[lang = "i8"]
impl i8 {
int_impl! { i8, i8, u8, 8, -128, 127, "", "" }
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa" }
}

#[lang = "i16"]
impl i16 {
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "" }
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
}

#[lang = "i32"]
impl i32 {
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "" }
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
}

#[lang = "i64"]
impl i64 {
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" }
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12,
"0xaa00000000006e1", "0x6e10aa" }
}

#[lang = "i128"]
impl i128 {
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
170141183460469231731687303715884105727, "", "" }
170141183460469231731687303715884105727, "", "", 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4"
}
}

#[cfg(target_pointer_width = "16")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i16, u16, 16, -32768, 32767, "", "" }
int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
}

#[cfg(target_pointer_width = "32")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "" }
int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
}

#[cfg(target_pointer_width = "64")]
#[lang = "isize"]
impl isize {
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" }
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "",
12, "0xaa00000000006e1", "0x6e10aa" }
}

// Emits the correct `cttz` call, depending on the size of the type.
Expand All @@ -2069,7 +2070,8 @@ macro_rules! uint_cttz_call {

// `Int` + `UnsignedInt` implemented for unsigned integers
macro_rules! uint_impl {
($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr) => {
($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
$rot:expr, $rot_op:expr, $rot_result:expr) => {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
Expand Down Expand Up @@ -2210,57 +2212,55 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
}
}

/// Shifts the bits to the left by a specified amount, `n`,
/// wrapping the truncated bits to the end of the resulting integer.
///
/// Please note this isn't the same operation as `<<`!
///
/// # Examples
///
/// Basic usage:
///
/// Please note that this example is shared between integer types.
/// Which explains why `u64` is used here.
///
/// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0x3456789ABCDEF012u64;
///
/// assert_eq!(n.rotate_left(12), m);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_left(self, n: u32) -> Self {
// Protect against undefined behaviour for over-long bit shifts
let n = n % $BITS;
(self << n) | (self >> (($BITS - n) % $BITS))
doc_comment! {
concat!("Shifts the bits to the left by a specified amount, `n`,
wrapping the truncated bits to the end of the resulting integer.
Please note this isn't the same operation as `<<`!
# Examples
Basic usage:
```
let n = ", $rot_op, stringify!($SelfT), ";
let m = ", $rot_result, ";
assert_eq!(n.rotate_left(", $rot, "), m);
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_left(self, n: u32) -> Self {
// Protect against undefined behaviour for over-long bit shifts
let n = n % $BITS;
(self << n) | (self >> (($BITS - n) % $BITS))
}
}

/// Shifts the bits to the right by a specified amount, `n`,
/// wrapping the truncated bits to the beginning of the resulting
/// integer.
///
/// Please note this isn't the same operation as `>>`!
///
/// # Examples
///
/// Basic usage:
///
/// Please note that this example is shared between integer types.
/// Which explains why `u64` is used here.
///
/// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xDEF0123456789ABCu64;
///
/// assert_eq!(n.rotate_right(12), m);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_right(self, n: u32) -> Self {
// Protect against undefined behaviour for over-long bit shifts
let n = n % $BITS;
(self >> n) | (self << (($BITS - n) % $BITS))
doc_comment! {
concat!("Shifts the bits to the right by a specified amount, `n`,
wrapping the truncated bits to the beginning of the resulting
integer.
Please note this isn't the same operation as `>>`!
# Examples
Basic usage:
```
let n = ", $rot_result, stringify!($SelfT), ";
let m = ", $rot_op, ";
assert_eq!(n.rotate_right(", $rot, "), m);
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rotate_right(self, n: u32) -> Self {
// Protect against undefined behaviour for over-long bit shifts
let n = n % $BITS;
(self >> n) | (self << (($BITS - n) % $BITS))
}
}

/// Reverses the byte order of the integer.
Expand Down Expand Up @@ -3621,7 +3621,7 @@ $EndFeature, "

#[lang = "u8"]
impl u8 {
uint_impl! { u8, u8, 8, 255, "", "" }
uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa" }


/// Checks if the value is within the ASCII range.
Expand Down Expand Up @@ -4147,39 +4147,41 @@ impl u8 {

#[lang = "u16"]
impl u16 {
uint_impl! { u16, u16, 16, 65535, "", "" }
uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a" }
}

#[lang = "u32"]
impl u32 {
uint_impl! { u32, u32, 32, 4294967295, "", "" }
uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
}

#[lang = "u64"]
impl u64 {
uint_impl! { u64, u64, 64, 18446744073709551615, "", "" }
uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa" }
}

#[lang = "u128"]
impl u128 {
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" }
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16,
"0x13f40000000000000000000000004f76", "0x4f7613f4" }
}

#[cfg(target_pointer_width = "16")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u16, 16, 65536, "", "" }
uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a" }
}
#[cfg(target_pointer_width = "32")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u32, 32, 4294967295, "", "" }
uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
}

#[cfg(target_pointer_width = "64")]
#[lang = "usize"]
impl usize {
uint_impl! { usize, u64, 64, 18446744073709551615, "", "" }
uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1",
"0x6e10aa" }
}

/// A classification of floating point numbers.
Expand Down

0 comments on commit 8958ed6

Please sign in to comment.