Skip to content

Commit 07a3429

Browse files
committed
Auto merge of #40867 - alexcrichton:rollup, r=alexcrichton
Rollup of 19 pull requests - Successful merges: #40317, #40516, #40524, #40606, #40683, #40751, #40778, #40813, #40818, #40819, #40824, #40828, #40832, #40833, #40837, #40849, #40852, #40853, #40865 - Failed merges:
2 parents ccce2c6 + 61928a0 commit 07a3429

File tree

93 files changed

+974
-592
lines changed

Some content is hidden

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

93 files changed

+974
-592
lines changed

appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ environment:
4646
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-ninja
4747
SCRIPT: python x.py test
4848
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
49-
MINGW_ARCHIVE: i686-6.3.0-release-win32-dwarf-rt_v5-rev1.7z
49+
MINGW_ARCHIVE: i686-6.2.0-release-win32-dwarf-rt_v5-rev1.7z
5050
MINGW_DIR: mingw32
5151
- MSYS_BITS: 64
5252
SCRIPT: python x.py test
5353
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-ninja
5454
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
55-
MINGW_ARCHIVE: x86_64-6.3.0-release-win32-seh-rt_v5-rev1.7z
55+
MINGW_ARCHIVE: x86_64-6.2.0-release-win32-seh-rt_v5-rev1.7z
5656
MINGW_DIR: mingw64
5757

5858
# 32/64 bit MSVC and GNU deployment
@@ -71,14 +71,14 @@ environment:
7171
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-extended --enable-ninja
7272
SCRIPT: python x.py dist
7373
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
74-
MINGW_ARCHIVE: i686-6.3.0-release-win32-dwarf-rt_v5-rev1.7z
74+
MINGW_ARCHIVE: i686-6.2.0-release-win32-dwarf-rt_v5-rev1.7z
7575
MINGW_DIR: mingw32
7676
DEPLOY: 1
7777
- MSYS_BITS: 64
7878
SCRIPT: python x.py dist
7979
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-extended --enable-ninja
8080
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
81-
MINGW_ARCHIVE: x86_64-6.3.0-release-win32-seh-rt_v5-rev1.7z
81+
MINGW_ARCHIVE: x86_64-6.2.0-release-win32-seh-rt_v5-rev1.7z
8282
MINGW_DIR: mingw64
8383
DEPLOY: 1
8484

src/bootstrap/bin/rustdoc.rs

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ fn main() {
4040
.arg(sysroot)
4141
.env(bootstrap::util::dylib_path_var(),
4242
env::join_paths(&dylib_path).unwrap());
43+
44+
// Pass the `rustbuild` feature flag to crates which rustbuild is
45+
// building. See the comment in bootstrap/lib.rs where this env var is
46+
// set for more details.
47+
if env::var_os("RUSTBUILD_UNSTABLE").is_some() {
48+
cmd.arg("--cfg").arg("rustbuild");
49+
}
50+
4351
std::process::exit(match cmd.status() {
4452
Ok(s) => s.code().unwrap_or(1),
4553
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn android_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
586586
.arg(ADB_TEST_DIR));
587587

588588
let target_dir = format!("{}/{}", ADB_TEST_DIR, target);
589-
build.run(Command::new("adb").args(&["shell", "mkdir", &target_dir[..]]));
589+
build.run(Command::new("adb").args(&["shell", "mkdir", &target_dir]));
590590

591591
for f in t!(build.sysroot_libdir(compiler, target).read_dir()) {
592592
let f = t!(f);

src/grammar/verify.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>, surrogate_
196196
let toknum = &s[content_end + 3 .. toknum_end];
197197

198198
let not_found = format!("didn't find token {:?} in the map", toknum);
199-
let proto_tok = tokens.get(toknum).expect(&not_found[..]);
199+
let proto_tok = tokens.get(toknum).expect(&not_found);
200200

201201
let nm = Symbol::intern(content);
202202

@@ -304,14 +304,14 @@ fn main() {
304304
let mut token_file = File::open(&Path::new(&args.next().unwrap())).unwrap();
305305
let mut token_list = String::new();
306306
token_file.read_to_string(&mut token_list).unwrap();
307-
let token_map = parse_token_list(&token_list[..]);
307+
let token_map = parse_token_list(&token_list);
308308

309309
let stdin = std::io::stdin();
310310
let lock = stdin.lock();
311311
let lines = lock.lines();
312312
let antlr_tokens = lines.map(|l| parse_antlr_token(l.unwrap().trim(),
313313
&token_map,
314-
&surrogate_pairs_pos[..],
314+
&surrogate_pairs_pos,
315315
has_bom));
316316

317317
for antlr_tok in antlr_tokens {

src/libcollections/linked_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ mod tests {
13761376
thread::spawn(move || {
13771377
check_links(&n);
13781378
let a: &[_] = &[&1, &2, &3];
1379-
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
1379+
assert_eq!(a, &*n.iter().collect::<Vec<_>>());
13801380
})
13811381
.join()
13821382
.ok()

src/libcore/ops.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub trait Drop {
196196
fn drop(&mut self);
197197
}
198198

199-
/// The `Add` trait is used to specify the functionality of `+`.
199+
/// The addition operator `+`.
200200
///
201201
/// # Examples
202202
///
@@ -269,7 +269,7 @@ macro_rules! add_impl {
269269

270270
add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
271271

272-
/// The `Sub` trait is used to specify the functionality of `-`.
272+
/// The subtraction operator `-`.
273273
///
274274
/// # Examples
275275
///
@@ -342,7 +342,7 @@ macro_rules! sub_impl {
342342

343343
sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
344344

345-
/// The `Mul` trait is used to specify the functionality of `*`.
345+
/// The multiplication operator `*`.
346346
///
347347
/// # Examples
348348
///
@@ -464,7 +464,7 @@ macro_rules! mul_impl {
464464

465465
mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
466466

467-
/// The `Div` trait is used to specify the functionality of `/`.
467+
/// The division operator `/`.
468468
///
469469
/// # Examples
470470
///
@@ -609,7 +609,7 @@ macro_rules! div_impl_float {
609609

610610
div_impl_float! { f32 f64 }
611611

612-
/// The `Rem` trait is used to specify the functionality of `%`.
612+
/// The remainder operator `%`.
613613
///
614614
/// # Examples
615615
///
@@ -689,7 +689,7 @@ macro_rules! rem_impl_float {
689689

690690
rem_impl_float! { f32 f64 }
691691

692-
/// The `Neg` trait is used to specify the functionality of unary `-`.
692+
/// The unary negation operator `-`.
693693
///
694694
/// # Examples
695695
///
@@ -768,7 +768,7 @@ macro_rules! neg_impl_unsigned {
768768
// neg_impl_unsigned! { usize u8 u16 u32 u64 }
769769
neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
770770

771-
/// The `Not` trait is used to specify the functionality of unary `!`.
771+
/// The unary logical negation operator `!`.
772772
///
773773
/// # Examples
774774
///
@@ -826,7 +826,7 @@ macro_rules! not_impl {
826826

827827
not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
828828

829-
/// The `BitAnd` trait is used to specify the functionality of `&`.
829+
/// The bitwise AND operator `&`.
830830
///
831831
/// # Examples
832832
///
@@ -909,7 +909,7 @@ macro_rules! bitand_impl {
909909

910910
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
911911

912-
/// The `BitOr` trait is used to specify the functionality of `|`.
912+
/// The bitwise OR operator `|`.
913913
///
914914
/// # Examples
915915
///
@@ -992,7 +992,7 @@ macro_rules! bitor_impl {
992992

993993
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
994994

995-
/// The `BitXor` trait is used to specify the functionality of `^`.
995+
/// The bitwise XOR operator `^`.
996996
///
997997
/// # Examples
998998
///
@@ -1078,7 +1078,7 @@ macro_rules! bitxor_impl {
10781078

10791079
bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
10801080

1081-
/// The `Shl` trait is used to specify the functionality of `<<`.
1081+
/// The left shift operator `<<`.
10821082
///
10831083
/// # Examples
10841084
///
@@ -1181,7 +1181,7 @@ macro_rules! shl_impl_all {
11811181

11821182
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
11831183

1184-
/// The `Shr` trait is used to specify the functionality of `>>`.
1184+
/// The right shift operator `>>`.
11851185
///
11861186
/// # Examples
11871187
///
@@ -1284,7 +1284,7 @@ macro_rules! shr_impl_all {
12841284

12851285
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
12861286

1287-
/// The `AddAssign` trait is used to specify the functionality of `+=`.
1287+
/// The addition assignment operator `+=`.
12881288
///
12891289
/// # Examples
12901290
///
@@ -1340,7 +1340,7 @@ macro_rules! add_assign_impl {
13401340

13411341
add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
13421342

1343-
/// The `SubAssign` trait is used to specify the functionality of `-=`.
1343+
/// The subtraction assignment operator `-=`.
13441344
///
13451345
/// # Examples
13461346
///
@@ -1396,7 +1396,7 @@ macro_rules! sub_assign_impl {
13961396

13971397
sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
13981398

1399-
/// The `MulAssign` trait is used to specify the functionality of `*=`.
1399+
/// The multiplication assignment operator `*=`.
14001400
///
14011401
/// # Examples
14021402
///
@@ -1441,7 +1441,7 @@ macro_rules! mul_assign_impl {
14411441

14421442
mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
14431443

1444-
/// The `DivAssign` trait is used to specify the functionality of `/=`.
1444+
/// The division assignment operator `/=`.
14451445
///
14461446
/// # Examples
14471447
///
@@ -1485,7 +1485,7 @@ macro_rules! div_assign_impl {
14851485

14861486
div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
14871487

1488-
/// The `RemAssign` trait is used to specify the functionality of `%=`.
1488+
/// The remainder assignment operator `%=`.
14891489
///
14901490
/// # Examples
14911491
///
@@ -1529,7 +1529,7 @@ macro_rules! rem_assign_impl {
15291529

15301530
rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
15311531

1532-
/// The `BitAndAssign` trait is used to specify the functionality of `&=`.
1532+
/// The bitwise AND assignment operator `&=`.
15331533
///
15341534
/// # Examples
15351535
///
@@ -1615,7 +1615,7 @@ macro_rules! bitand_assign_impl {
16151615

16161616
bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
16171617

1618-
/// The `BitOrAssign` trait is used to specify the functionality of `|=`.
1618+
/// The bitwise OR assignment operator `|=`.
16191619
///
16201620
/// # Examples
16211621
///
@@ -1659,7 +1659,7 @@ macro_rules! bitor_assign_impl {
16591659

16601660
bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
16611661

1662-
/// The `BitXorAssign` trait is used to specify the functionality of `^=`.
1662+
/// The bitwise XOR assignment operator `^=`.
16631663
///
16641664
/// # Examples
16651665
///
@@ -1703,7 +1703,7 @@ macro_rules! bitxor_assign_impl {
17031703

17041704
bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
17051705

1706-
/// The `ShlAssign` trait is used to specify the functionality of `<<=`.
1706+
/// The left shift assignment operator `<<=`.
17071707
///
17081708
/// # Examples
17091709
///
@@ -1768,7 +1768,7 @@ macro_rules! shl_assign_impl_all {
17681768

17691769
shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
17701770

1771-
/// The `ShrAssign` trait is used to specify the functionality of `>>=`.
1771+
/// The right shift assignment operator `>>=`.
17721772
///
17731773
/// # Examples
17741774
///

src/libcore/slice/sort.rs

+32-24
Original file line numberDiff line numberDiff line change
@@ -498,32 +498,40 @@ fn partition_equal<T, F>(v: &mut [T], pivot: usize, is_less: &mut F) -> usize
498498
#[cold]
499499
fn break_patterns<T>(v: &mut [T]) {
500500
let len = v.len();
501-
502501
if len >= 8 {
503-
// A random number will be taken modulo this one. The modulus is a power of two so that we
504-
// can simply take bitwise "and", thus avoiding costly CPU operations.
505-
let modulus = (len / 4).next_power_of_two();
506-
debug_assert!(modulus >= 1 && modulus <= len / 2);
507-
508-
// Pseudorandom number generation from the "Xorshift RNGs" paper by George Marsaglia.
509-
let mut random = len;
510-
random ^= random << 13;
511-
random ^= random >> 17;
512-
random ^= random << 5;
513-
random &= modulus - 1;
514-
debug_assert!(random < len / 2);
515-
516-
// The first index.
517-
let a = len / 4 * 2;
518-
debug_assert!(a >= 1 && a < len - 2);
519-
520-
// The second index.
521-
let b = len / 4 + random;
522-
debug_assert!(b >= 1 && b < len - 2);
523-
524-
// Swap neighbourhoods of `a` and `b`.
502+
// Pseudorandom number generator from the "Xorshift RNGs" paper by George Marsaglia.
503+
let mut random = len as u32;
504+
let mut gen_u32 = || {
505+
random ^= random << 13;
506+
random ^= random >> 17;
507+
random ^= random << 5;
508+
random
509+
};
510+
let mut gen_usize = || {
511+
if mem::size_of::<usize>() <= 4 {
512+
gen_u32() as usize
513+
} else {
514+
(((gen_u32() as u64) << 32) | (gen_u32() as u64)) as usize
515+
}
516+
};
517+
518+
// Take random numbers modulo this number.
519+
// The number fits into `usize` because `len` is not greater than `isize::MAX`.
520+
let modulus = len.next_power_of_two();
521+
522+
// Some pivot candidates will be in the nearby of this index. Let's randomize them.
523+
let pos = len / 4 * 2;
524+
525525
for i in 0..3 {
526-
v.swap(a - 1 + i, b - 1 + i);
526+
// Generate a random number modulo `len`. However, in order to avoid costly operations
527+
// we first take it modulo a power of two, and then decrease by `len` until it fits
528+
// into the range `[0, len - 1]`.
529+
let mut other = gen_usize() & (modulus - 1);
530+
while other >= len {
531+
other -= len;
532+
}
533+
534+
v.swap(pos - 1 + i, other);
527535
}
528536
}
529537
}

0 commit comments

Comments
 (0)