Skip to content

Commit 8958ed6

Browse files
committed
Auto merge of #53216 - kennytm:rollup, r=kennytm
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)
2 parents b73535f + 9f55705 commit 8958ed6

File tree

98 files changed

+791
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+791
-409
lines changed

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
#![cfg_attr(not(test), feature(fn_traits))]
7878
#![cfg_attr(not(test), feature(generator_trait))]
79+
#![cfg_attr(not(stage0), feature(nll))]
7980
#![cfg_attr(test, feature(test))]
8081

8182
#![feature(allocator_api)]

src/liballoc_jemalloc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![feature(core_intrinsics)]
1717
#![feature(libc)]
1818
#![feature(linkage)]
19+
#![cfg_attr(not(stage0), feature(nll))]
1920
#![feature(staged_api)]
2021
#![feature(rustc_attrs)]
2122
#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))]

src/liballoc_system/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
reason = "this library is unlikely to be stabilized in its current \
1515
form or name",
1616
issue = "32838")]
17+
1718
#![feature(allocator_api)]
1819
#![feature(core_intrinsics)]
20+
#![cfg_attr(not(stage0), feature(nll))]
1921
#![feature(staged_api)]
2022
#![feature(rustc_attrs)]
2123
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]

src/libarena/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![feature(alloc)]
2727
#![feature(core_intrinsics)]
2828
#![feature(dropck_eyepatch)]
29+
#![cfg_attr(not(stage0), feature(nll))]
2930
#![feature(raw_vec_internals)]
3031
#![cfg_attr(test, feature(test))]
3132

src/libcore/cmp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
469469
/// assert_eq!(2, 2.max(2));
470470
/// ```
471471
#[stable(feature = "ord_max_min", since = "1.21.0")]
472+
#[inline]
472473
fn max(self, other: Self) -> Self
473474
where Self: Sized {
474475
if other >= self { other } else { self }
@@ -485,6 +486,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
485486
/// assert_eq!(2, 2.min(2));
486487
/// ```
487488
#[stable(feature = "ord_max_min", since = "1.21.0")]
489+
#[inline]
488490
fn min(self, other: Self) -> Self
489491
where Self: Sized {
490492
if self <= other { self } else { other }

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<T: ?Sized> !Send for *mut T { }
9595
message="the size for values of type `{Self}` cannot be known at compilation time",
9696
label="doesn't have a size known at compile-time",
9797
note="to learn more, visit <https://doc.rust-lang.org/book/second-edition/\
98-
ch19-04-advanced-types.html#dynamically-sized-types-and-sized>",
98+
ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>",
9999
)]
100100
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
101101
pub trait Sized {

src/libcore/num/mod.rs

+115-113
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ mod wrapping;
188188
// `Int` + `SignedInt` implemented for signed integers
189189
macro_rules! int_impl {
190190
($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr, $Feature:expr,
191-
$EndFeature:expr) => {
191+
$EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr) => {
192192
doc_comment! {
193193
concat!("Returns the smallest value that can be represented by this integer type.
194194
@@ -334,55 +334,52 @@ $EndFeature, "
334334
}
335335
}
336336

337-
/// Shifts the bits to the left by a specified amount, `n`,
338-
/// wrapping the truncated bits to the end of the resulting integer.
339-
///
340-
/// Please note this isn't the same operation as `<<`!
341-
///
342-
/// # Examples
343-
///
344-
/// Please note that this example is shared between integer types.
345-
/// Which explains why `i64` is used here.
346-
///
347-
/// Basic usage:
348-
///
349-
/// ```
350-
/// let n = 0x0123456789ABCDEFi64;
351-
/// let m = -0x76543210FEDCBA99i64;
352-
///
353-
/// assert_eq!(n.rotate_left(32), m);
354-
/// ```
355-
#[stable(feature = "rust1", since = "1.0.0")]
356-
#[inline]
357-
pub fn rotate_left(self, n: u32) -> Self {
358-
(self as $UnsignedT).rotate_left(n) as Self
359-
}
337+
doc_comment! {
338+
concat!("Shifts the bits to the left by a specified amount, `n`,
339+
wrapping the truncated bits to the end of the resulting integer.
360340
361-
/// Shifts the bits to the right by a specified amount, `n`,
362-
/// wrapping the truncated bits to the beginning of the resulting
363-
/// integer.
364-
///
365-
/// Please note this isn't the same operation as `>>`!
366-
///
367-
/// # Examples
368-
///
369-
/// Please note that this example is shared between integer types.
370-
/// Which explains why `i64` is used here.
371-
///
372-
/// Basic usage:
373-
///
374-
/// ```
375-
/// let n = 0x0123456789ABCDEFi64;
376-
/// let m = -0xFEDCBA987654322i64;
377-
///
378-
/// assert_eq!(n.rotate_right(4), m);
379-
/// ```
380-
#[stable(feature = "rust1", since = "1.0.0")]
381-
#[inline]
382-
pub fn rotate_right(self, n: u32) -> Self {
383-
(self as $UnsignedT).rotate_right(n) as Self
341+
Please note this isn't the same operation as `<<`!
342+
343+
# Examples
344+
345+
Basic usage:
346+
347+
```
348+
let n = ", $rot_op, stringify!($SelfT), ";
349+
let m = ", $rot_result, ";
350+
351+
assert_eq!(n.rotate_left(", $rot, "), m);
352+
```"),
353+
#[stable(feature = "rust1", since = "1.0.0")]
354+
#[inline]
355+
pub fn rotate_left(self, n: u32) -> Self {
356+
(self as $UnsignedT).rotate_left(n) as Self
357+
}
384358
}
385359

360+
doc_comment! {
361+
concat!("Shifts the bits to the right by a specified amount, `n`,
362+
wrapping the truncated bits to the beginning of the resulting
363+
integer.
364+
365+
Please note this isn't the same operation as `>>`!
366+
367+
# Examples
368+
369+
Basic usage:
370+
371+
```
372+
let n = ", $rot_result, stringify!($SelfT), ";
373+
let m = ", $rot_op, ";
374+
375+
assert_eq!(n.rotate_right(", $rot, "), m);
376+
```"),
377+
#[stable(feature = "rust1", since = "1.0.0")]
378+
#[inline]
379+
pub fn rotate_right(self, n: u32) -> Self {
380+
(self as $UnsignedT).rotate_right(n) as Self
381+
}
382+
}
386383
/// Reverses the byte order of the integer.
387384
///
388385
/// # Examples
@@ -2012,46 +2009,50 @@ $EndFeature, "
20122009

20132010
#[lang = "i8"]
20142011
impl i8 {
2015-
int_impl! { i8, i8, u8, 8, -128, 127, "", "" }
2012+
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa" }
20162013
}
20172014

20182015
#[lang = "i16"]
20192016
impl i16 {
2020-
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "" }
2017+
int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
20212018
}
20222019

20232020
#[lang = "i32"]
20242021
impl i32 {
2025-
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "" }
2022+
int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
20262023
}
20272024

20282025
#[lang = "i64"]
20292026
impl i64 {
2030-
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" }
2027+
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12,
2028+
"0xaa00000000006e1", "0x6e10aa" }
20312029
}
20322030

20332031
#[lang = "i128"]
20342032
impl i128 {
20352033
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
2036-
170141183460469231731687303715884105727, "", "" }
2034+
170141183460469231731687303715884105727, "", "", 16,
2035+
"0x13f40000000000000000000000004f76", "0x4f7613f4"
2036+
}
20372037
}
20382038

20392039
#[cfg(target_pointer_width = "16")]
20402040
#[lang = "isize"]
20412041
impl isize {
2042-
int_impl! { isize, i16, u16, 16, -32768, 32767, "", "" }
2042+
int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
20432043
}
20442044

20452045
#[cfg(target_pointer_width = "32")]
20462046
#[lang = "isize"]
20472047
impl isize {
2048-
int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "" }
2048+
int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
20492049
}
20502050

20512051
#[cfg(target_pointer_width = "64")]
20522052
#[lang = "isize"]
20532053
impl isize {
2054-
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" }
2054+
int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "",
2055+
12, "0xaa00000000006e1", "0x6e10aa" }
20552056
}
20562057

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

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

2213-
/// Shifts the bits to the left by a specified amount, `n`,
2214-
/// wrapping the truncated bits to the end of the resulting integer.
2215-
///
2216-
/// Please note this isn't the same operation as `<<`!
2217-
///
2218-
/// # Examples
2219-
///
2220-
/// Basic usage:
2221-
///
2222-
/// Please note that this example is shared between integer types.
2223-
/// Which explains why `u64` is used here.
2224-
///
2225-
/// ```
2226-
/// let n = 0x0123456789ABCDEFu64;
2227-
/// let m = 0x3456789ABCDEF012u64;
2228-
///
2229-
/// assert_eq!(n.rotate_left(12), m);
2230-
/// ```
2231-
#[stable(feature = "rust1", since = "1.0.0")]
2232-
#[inline]
2233-
pub fn rotate_left(self, n: u32) -> Self {
2234-
// Protect against undefined behaviour for over-long bit shifts
2235-
let n = n % $BITS;
2236-
(self << n) | (self >> (($BITS - n) % $BITS))
2215+
doc_comment! {
2216+
concat!("Shifts the bits to the left by a specified amount, `n`,
2217+
wrapping the truncated bits to the end of the resulting integer.
2218+
2219+
Please note this isn't the same operation as `<<`!
2220+
2221+
# Examples
2222+
2223+
Basic usage:
2224+
2225+
```
2226+
let n = ", $rot_op, stringify!($SelfT), ";
2227+
let m = ", $rot_result, ";
2228+
2229+
assert_eq!(n.rotate_left(", $rot, "), m);
2230+
```"),
2231+
#[stable(feature = "rust1", since = "1.0.0")]
2232+
#[inline]
2233+
pub fn rotate_left(self, n: u32) -> Self {
2234+
// Protect against undefined behaviour for over-long bit shifts
2235+
let n = n % $BITS;
2236+
(self << n) | (self >> (($BITS - n) % $BITS))
2237+
}
22372238
}
22382239

2239-
/// Shifts the bits to the right by a specified amount, `n`,
2240-
/// wrapping the truncated bits to the beginning of the resulting
2241-
/// integer.
2242-
///
2243-
/// Please note this isn't the same operation as `>>`!
2244-
///
2245-
/// # Examples
2246-
///
2247-
/// Basic usage:
2248-
///
2249-
/// Please note that this example is shared between integer types.
2250-
/// Which explains why `u64` is used here.
2251-
///
2252-
/// ```
2253-
/// let n = 0x0123456789ABCDEFu64;
2254-
/// let m = 0xDEF0123456789ABCu64;
2255-
///
2256-
/// assert_eq!(n.rotate_right(12), m);
2257-
/// ```
2258-
#[stable(feature = "rust1", since = "1.0.0")]
2259-
#[inline]
2260-
pub fn rotate_right(self, n: u32) -> Self {
2261-
// Protect against undefined behaviour for over-long bit shifts
2262-
let n = n % $BITS;
2263-
(self >> n) | (self << (($BITS - n) % $BITS))
2240+
doc_comment! {
2241+
concat!("Shifts the bits to the right by a specified amount, `n`,
2242+
wrapping the truncated bits to the beginning of the resulting
2243+
integer.
2244+
2245+
Please note this isn't the same operation as `>>`!
2246+
2247+
# Examples
2248+
2249+
Basic usage:
2250+
2251+
```
2252+
let n = ", $rot_result, stringify!($SelfT), ";
2253+
let m = ", $rot_op, ";
2254+
2255+
assert_eq!(n.rotate_right(", $rot, "), m);
2256+
```"),
2257+
#[stable(feature = "rust1", since = "1.0.0")]
2258+
#[inline]
2259+
pub fn rotate_right(self, n: u32) -> Self {
2260+
// Protect against undefined behaviour for over-long bit shifts
2261+
let n = n % $BITS;
2262+
(self >> n) | (self << (($BITS - n) % $BITS))
2263+
}
22642264
}
22652265

22662266
/// Reverses the byte order of the integer.
@@ -3621,7 +3621,7 @@ $EndFeature, "
36213621

36223622
#[lang = "u8"]
36233623
impl u8 {
3624-
uint_impl! { u8, u8, 8, 255, "", "" }
3624+
uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa" }
36253625

36263626

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

41484148
#[lang = "u16"]
41494149
impl u16 {
4150-
uint_impl! { u16, u16, 16, 65535, "", "" }
4150+
uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a" }
41514151
}
41524152

41534153
#[lang = "u32"]
41544154
impl u32 {
4155-
uint_impl! { u32, u32, 32, 4294967295, "", "" }
4155+
uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
41564156
}
41574157

41584158
#[lang = "u64"]
41594159
impl u64 {
4160-
uint_impl! { u64, u64, 64, 18446744073709551615, "", "" }
4160+
uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa" }
41614161
}
41624162

41634163
#[lang = "u128"]
41644164
impl u128 {
4165-
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" }
4165+
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16,
4166+
"0x13f40000000000000000000000004f76", "0x4f7613f4" }
41664167
}
41674168

41684169
#[cfg(target_pointer_width = "16")]
41694170
#[lang = "usize"]
41704171
impl usize {
4171-
uint_impl! { usize, u16, 16, 65536, "", "" }
4172+
uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a" }
41724173
}
41734174
#[cfg(target_pointer_width = "32")]
41744175
#[lang = "usize"]
41754176
impl usize {
4176-
uint_impl! { usize, u32, 32, 4294967295, "", "" }
4177+
uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
41774178
}
41784179

41794180
#[cfg(target_pointer_width = "64")]
41804181
#[lang = "usize"]
41814182
impl usize {
4182-
uint_impl! { usize, u64, 64, 18446744073709551615, "", "" }
4183+
uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1",
4184+
"0x6e10aa" }
41834185
}
41844186

41854187
/// A classification of floating point numbers.

0 commit comments

Comments
 (0)