Skip to content

Commit

Permalink
Auto merge of #40867 - alexcrichton:rollup, r=alexcrichton
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
bors committed Mar 28, 2017
2 parents ccce2c6 + 61928a0 commit 07a3429
Show file tree
Hide file tree
Showing 93 changed files with 974 additions and 592 deletions.
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ environment:
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-ninja
SCRIPT: python x.py test
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
MINGW_ARCHIVE: i686-6.3.0-release-win32-dwarf-rt_v5-rev1.7z
MINGW_ARCHIVE: i686-6.2.0-release-win32-dwarf-rt_v5-rev1.7z
MINGW_DIR: mingw32
- MSYS_BITS: 64
SCRIPT: python x.py test
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-ninja
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
MINGW_ARCHIVE: x86_64-6.3.0-release-win32-seh-rt_v5-rev1.7z
MINGW_ARCHIVE: x86_64-6.2.0-release-win32-seh-rt_v5-rev1.7z
MINGW_DIR: mingw64

# 32/64 bit MSVC and GNU deployment
Expand All @@ -71,14 +71,14 @@ environment:
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-extended --enable-ninja
SCRIPT: python x.py dist
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
MINGW_ARCHIVE: i686-6.3.0-release-win32-dwarf-rt_v5-rev1.7z
MINGW_ARCHIVE: i686-6.2.0-release-win32-dwarf-rt_v5-rev1.7z
MINGW_DIR: mingw32
DEPLOY: 1
- MSYS_BITS: 64
SCRIPT: python x.py dist
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-extended --enable-ninja
MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror
MINGW_ARCHIVE: x86_64-6.3.0-release-win32-seh-rt_v5-rev1.7z
MINGW_ARCHIVE: x86_64-6.2.0-release-win32-seh-rt_v5-rev1.7z
MINGW_DIR: mingw64
DEPLOY: 1

Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ fn main() {
.arg(sysroot)
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());

// Pass the `rustbuild` feature flag to crates which rustbuild is
// building. See the comment in bootstrap/lib.rs where this env var is
// set for more details.
if env::var_os("RUSTBUILD_UNSTABLE").is_some() {
cmd.arg("--cfg").arg("rustbuild");
}

std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ fn android_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
.arg(ADB_TEST_DIR));

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

for f in t!(build.sysroot_libdir(compiler, target).read_dir()) {
let f = t!(f);
Expand Down
6 changes: 3 additions & 3 deletions src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>, surrogate_
let toknum = &s[content_end + 3 .. toknum_end];

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

let nm = Symbol::intern(content);

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

let stdin = std::io::stdin();
let lock = stdin.lock();
let lines = lock.lines();
let antlr_tokens = lines.map(|l| parse_antlr_token(l.unwrap().trim(),
&token_map,
&surrogate_pairs_pos[..],
&surrogate_pairs_pos,
has_bom));

for antlr_tok in antlr_tokens {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ mod tests {
thread::spawn(move || {
check_links(&n);
let a: &[_] = &[&1, &2, &3];
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
assert_eq!(a, &*n.iter().collect::<Vec<_>>());
})
.join()
.ok()
Expand Down
44 changes: 22 additions & 22 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub trait Drop {
fn drop(&mut self);
}

/// The `Add` trait is used to specify the functionality of `+`.
/// The addition operator `+`.
///
/// # Examples
///
Expand Down Expand Up @@ -269,7 +269,7 @@ macro_rules! add_impl {

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

/// The `Sub` trait is used to specify the functionality of `-`.
/// The subtraction operator `-`.
///
/// # Examples
///
Expand Down Expand Up @@ -342,7 +342,7 @@ macro_rules! sub_impl {

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

/// The `Mul` trait is used to specify the functionality of `*`.
/// The multiplication operator `*`.
///
/// # Examples
///
Expand Down Expand Up @@ -464,7 +464,7 @@ macro_rules! mul_impl {

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

/// The `Div` trait is used to specify the functionality of `/`.
/// The division operator `/`.
///
/// # Examples
///
Expand Down Expand Up @@ -609,7 +609,7 @@ macro_rules! div_impl_float {

div_impl_float! { f32 f64 }

/// The `Rem` trait is used to specify the functionality of `%`.
/// The remainder operator `%`.
///
/// # Examples
///
Expand Down Expand Up @@ -689,7 +689,7 @@ macro_rules! rem_impl_float {

rem_impl_float! { f32 f64 }

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

/// The `Not` trait is used to specify the functionality of unary `!`.
/// The unary logical negation operator `!`.
///
/// # Examples
///
Expand Down Expand Up @@ -826,7 +826,7 @@ macro_rules! not_impl {

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

/// The `BitAnd` trait is used to specify the functionality of `&`.
/// The bitwise AND operator `&`.
///
/// # Examples
///
Expand Down Expand Up @@ -909,7 +909,7 @@ macro_rules! bitand_impl {

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

/// The `BitOr` trait is used to specify the functionality of `|`.
/// The bitwise OR operator `|`.
///
/// # Examples
///
Expand Down Expand Up @@ -992,7 +992,7 @@ macro_rules! bitor_impl {

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

/// The `BitXor` trait is used to specify the functionality of `^`.
/// The bitwise XOR operator `^`.
///
/// # Examples
///
Expand Down Expand Up @@ -1078,7 +1078,7 @@ macro_rules! bitxor_impl {

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

/// The `Shl` trait is used to specify the functionality of `<<`.
/// The left shift operator `<<`.
///
/// # Examples
///
Expand Down Expand Up @@ -1181,7 +1181,7 @@ macro_rules! shl_impl_all {

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

/// The `Shr` trait is used to specify the functionality of `>>`.
/// The right shift operator `>>`.
///
/// # Examples
///
Expand Down Expand Up @@ -1284,7 +1284,7 @@ macro_rules! shr_impl_all {

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

/// The `AddAssign` trait is used to specify the functionality of `+=`.
/// The addition assignment operator `+=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1340,7 +1340,7 @@ macro_rules! add_assign_impl {

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

/// The `SubAssign` trait is used to specify the functionality of `-=`.
/// The subtraction assignment operator `-=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1396,7 +1396,7 @@ macro_rules! sub_assign_impl {

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

/// The `MulAssign` trait is used to specify the functionality of `*=`.
/// The multiplication assignment operator `*=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1441,7 +1441,7 @@ macro_rules! mul_assign_impl {

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

/// The `DivAssign` trait is used to specify the functionality of `/=`.
/// The division assignment operator `/=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1485,7 +1485,7 @@ macro_rules! div_assign_impl {

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

/// The `RemAssign` trait is used to specify the functionality of `%=`.
/// The remainder assignment operator `%=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1529,7 +1529,7 @@ macro_rules! rem_assign_impl {

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

/// The `BitAndAssign` trait is used to specify the functionality of `&=`.
/// The bitwise AND assignment operator `&=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1615,7 +1615,7 @@ macro_rules! bitand_assign_impl {

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

/// The `BitOrAssign` trait is used to specify the functionality of `|=`.
/// The bitwise OR assignment operator `|=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1659,7 +1659,7 @@ macro_rules! bitor_assign_impl {

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

/// The `BitXorAssign` trait is used to specify the functionality of `^=`.
/// The bitwise XOR assignment operator `^=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1703,7 +1703,7 @@ macro_rules! bitxor_assign_impl {

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

/// The `ShlAssign` trait is used to specify the functionality of `<<=`.
/// The left shift assignment operator `<<=`.
///
/// # Examples
///
Expand Down Expand Up @@ -1768,7 +1768,7 @@ macro_rules! shl_assign_impl_all {

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

/// The `ShrAssign` trait is used to specify the functionality of `>>=`.
/// The right shift assignment operator `>>=`.
///
/// # Examples
///
Expand Down
56 changes: 32 additions & 24 deletions src/libcore/slice/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,32 +498,40 @@ fn partition_equal<T, F>(v: &mut [T], pivot: usize, is_less: &mut F) -> usize
#[cold]
fn break_patterns<T>(v: &mut [T]) {
let len = v.len();

if len >= 8 {
// A random number will be taken modulo this one. The modulus is a power of two so that we
// can simply take bitwise "and", thus avoiding costly CPU operations.
let modulus = (len / 4).next_power_of_two();
debug_assert!(modulus >= 1 && modulus <= len / 2);

// Pseudorandom number generation from the "Xorshift RNGs" paper by George Marsaglia.
let mut random = len;
random ^= random << 13;
random ^= random >> 17;
random ^= random << 5;
random &= modulus - 1;
debug_assert!(random < len / 2);

// The first index.
let a = len / 4 * 2;
debug_assert!(a >= 1 && a < len - 2);

// The second index.
let b = len / 4 + random;
debug_assert!(b >= 1 && b < len - 2);

// Swap neighbourhoods of `a` and `b`.
// Pseudorandom number generator from the "Xorshift RNGs" paper by George Marsaglia.
let mut random = len as u32;
let mut gen_u32 = || {
random ^= random << 13;
random ^= random >> 17;
random ^= random << 5;
random
};
let mut gen_usize = || {
if mem::size_of::<usize>() <= 4 {
gen_u32() as usize
} else {
(((gen_u32() as u64) << 32) | (gen_u32() as u64)) as usize
}
};

// Take random numbers modulo this number.
// The number fits into `usize` because `len` is not greater than `isize::MAX`.
let modulus = len.next_power_of_two();

// Some pivot candidates will be in the nearby of this index. Let's randomize them.
let pos = len / 4 * 2;

for i in 0..3 {
v.swap(a - 1 + i, b - 1 + i);
// Generate a random number modulo `len`. However, in order to avoid costly operations
// we first take it modulo a power of two, and then decrease by `len` until it fits
// into the range `[0, len - 1]`.
let mut other = gen_usize() & (modulus - 1);
while other >= len {
other -= len;
}

v.swap(pos - 1 + i, other);
}
}
}
Expand Down
Loading

0 comments on commit 07a3429

Please sign in to comment.