Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #67132

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ed56f86
Cleaned up unused labels
BartMassey Nov 12, 2019
34a45a5
Changed unused_labels lint default from allow to warn
BartMassey Nov 12, 2019
c874789
remove dependency from libhermit
stlankes Nov 25, 2019
e4b2cb8
Add support for RISC-V 64-bit GNU/Linux
msizanoen1 Nov 23, 2019
930a0a2
Update libc
msizanoen1 Nov 30, 2019
756aa1e
rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove u…
Nashenas88 Dec 3, 2019
9a21f6e
rustc_mir: Fix tidy line lengths
Nashenas88 Dec 3, 2019
a5e144b
rustc_codegen_ssa: Fix line accidentally reverted during rebase
Nashenas88 Dec 5, 2019
3f1e391
Exclude manually arranged ascii tables from rustfmt
dtolnay Nov 30, 2019
24d7f72
Suppress libcore/ptr/mod.rs filelength lint
dtolnay Nov 30, 2019
c737169
Format libcore with rustfmt (including tests and benches)
dtolnay Dec 7, 2019
c8850c7
Make `ForeignItem` an alias of `Item`.
Centril Nov 30, 2019
dfc04fc
Fixes typo
remexre Dec 7, 2019
7aed4c5
Rollup merge of #66325 - BartMassey:master, r=joshtriplett
Centril Dec 7, 2019
a89ab53
Rollup merge of #66730 - hermitcore:master, r=alexcrichton
Centril Dec 7, 2019
71643e2
Rollup merge of #66892 - dtolnay:fmt5, r=KodrAus
Centril Dec 7, 2019
8ed97e4
Rollup merge of #66899 - msizanoen1:riscv-std, r=alexcrichton
Centril Dec 7, 2019
6e9ead3
Rollup merge of #66991 - Nashenas88:body_cache_cleanup, r=eddyb
Centril Dec 7, 2019
010817d
Rollup merge of #67114 - Centril:foreign-item-alias, r=petrochenkov
Centril Dec 7, 2019
2f28648
Rollup merge of #67129 - remexre:patch-1, r=Dylan-DPC
Centril Dec 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1823,9 +1823,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"

[[package]]
name = "libc"
version = "0.2.64"
version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/benches/any.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::any::*;
use test::{Bencher, black_box};
use test::{black_box, Bencher};

#[bench]
fn bench_downcast_ref(b: &mut Bencher) {
Expand Down
22 changes: 10 additions & 12 deletions src/libcore/benches/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,9 @@
//
// Therefore:
fn branchless_to_ascii_upper_case(byte: u8) -> u8 {
byte &
!(
(
byte.wrapping_add(0x1f) &
!byte.wrapping_add(0x05) &
0x80
) >> 2
)
byte & !((byte.wrapping_add(0x1f) & !byte.wrapping_add(0x05) & 0x80) >> 2)
}


macro_rules! benches {
($( fn $name: ident($arg: ident: &mut [u8]) $body: block )+ @iter $( $is_: ident, )+) => {
benches! {@
Expand Down Expand Up @@ -254,12 +246,15 @@ benches! {
}

macro_rules! repeat {
($s: expr) => { concat!($s, $s, $s, $s, $s, $s, $s, $s, $s, $s) }
($s: expr) => {
concat!($s, $s, $s, $s, $s, $s, $s, $s, $s, $s)
};
}

const SHORT: &'static str = "Alice's";
const MEDIUM: &'static str = "Alice's Adventures in Wonderland";
const LONG: &'static str = repeat!(r#"
const LONG: &'static str = repeat!(
r#"
La Guida di Bragia, a Ballad Opera for the Marionette Theatre (around 1850)
Alice's Adventures in Wonderland (1865)
Phantasmagoria and Other Poems (1869)
Expand All @@ -275,8 +270,10 @@ const LONG: &'static str = repeat!(r#"
What the Tortoise Said to Achilles (1895)
Three Sunsets and Other Poems (1898)
The Manlet (1903)[106]
"#);
"#
);

#[rustfmt::skip]
const ASCII_UPPERCASE_MAP: [u8; 256] = [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
Expand Down Expand Up @@ -330,6 +327,7 @@ enum AsciiCharacterClass {
}
use self::AsciiCharacterClass::*;

#[rustfmt::skip]
static ASCII_CHARACTER_CLASS: [AsciiCharacterClass; 256] = [
// _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
C, C, C, C, C, C, C, C, C, Cw,Cw,C, Cw,Cw,C, C, // 0_
Expand Down
13 changes: 9 additions & 4 deletions src/libcore/benches/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ fn bench_to_digit_radix_36(b: &mut Bencher) {

#[bench]
fn bench_to_digit_radix_var(b: &mut Bencher) {
b.iter(|| CHARS.iter().cycle()
.zip(RADIX.iter().cycle())
.take(10_000)
.map(|(c, radix)| c.to_digit(*radix)).min())
b.iter(|| {
CHARS
.iter()
.cycle()
.zip(RADIX.iter().cycle())
.take(10_000)
.map(|(c, radix)| c.to_digit(*radix))
.min()
})
}
2 changes: 1 addition & 1 deletion src/libcore/benches/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::io::{self, Write as IoWrite};
use std::fmt::{self, Write as FmtWrite};
use std::io::{self, Write as IoWrite};
use test::Bencher;

#[bench]
Expand Down
48 changes: 15 additions & 33 deletions src/libcore/benches/hash/sip.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(deprecated)]

use core::hash::*;
use test::{Bencher, black_box};
use test::{black_box, Bencher};

fn hash_bytes<H: Hasher>(mut s: H, x: &[u8]) -> u64 {
Hasher::write(&mut s, x);
Expand Down Expand Up @@ -44,11 +44,11 @@ fn bench_str_over_8_bytes(b: &mut Bencher) {
#[bench]
fn bench_long_str(b: &mut Bencher) {
let s = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
officia deserunt mollit anim id est laborum.";
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
officia deserunt mollit anim id est laborum.";
b.iter(|| {
assert_eq!(hash(&s), 17717065544121360093);
})
Expand All @@ -58,9 +58,7 @@ officia deserunt mollit anim id est laborum.";
fn bench_u32(b: &mut Bencher) {
let u = 162629500u32;
let u = black_box(u);
b.iter(|| {
hash(&u)
});
b.iter(|| hash(&u));
b.bytes = 8;
}

Expand All @@ -70,72 +68,56 @@ fn bench_u32_keyed(b: &mut Bencher) {
let u = black_box(u);
let k1 = black_box(0x1);
let k2 = black_box(0x2);
b.iter(|| {
hash_with(SipHasher::new_with_keys(k1, k2), &u)
});
b.iter(|| hash_with(SipHasher::new_with_keys(k1, k2), &u));
b.bytes = 8;
}

#[bench]
fn bench_u64(b: &mut Bencher) {
let u = 16262950014981195938u64;
let u = black_box(u);
b.iter(|| {
hash(&u)
});
b.iter(|| hash(&u));
b.bytes = 8;
}

#[bench]
fn bench_bytes_4(b: &mut Bencher) {
let data = black_box([b' '; 4]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 4;
}

#[bench]
fn bench_bytes_7(b: &mut Bencher) {
let data = black_box([b' '; 7]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 7;
}

#[bench]
fn bench_bytes_8(b: &mut Bencher) {
let data = black_box([b' '; 8]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 8;
}

#[bench]
fn bench_bytes_a_16(b: &mut Bencher) {
let data = black_box([b' '; 16]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 16;
}

#[bench]
fn bench_bytes_b_32(b: &mut Bencher) {
let data = black_box([b' '; 32]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 32;
}

#[bench]
fn bench_bytes_c_128(b: &mut Bencher) {
let data = black_box([b' '; 128]);
b.iter(|| {
hash_bytes(SipHasher::default(), &data)
});
b.iter(|| hash_bytes(SipHasher::default(), &data));
b.bytes = 128;
}
65 changes: 33 additions & 32 deletions src/libcore/benches/iter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::iter::*;
use test::{Bencher, black_box};
use test::{black_box, Bencher};

#[bench]
fn bench_rposition(b: &mut Bencher) {
Expand All @@ -14,7 +14,11 @@ fn bench_skip_while(b: &mut Bencher) {
b.iter(|| {
let it = 0..100;
let mut sum = 0;
it.skip_while(|&x| { sum += x; sum < 4000 }).all(|_| true);
it.skip_while(|&x| {
sum += x;
sum < 4000
})
.all(|_| true);
});
}

Expand All @@ -29,7 +33,9 @@ fn bench_multiple_take(b: &mut Bencher) {
});
}

fn scatter(x: i32) -> i32 { (x * 31) % 127 }
fn scatter(x: i32) -> i32 {
(x * 31) % 127
}

#[bench]
fn bench_max_by_key(b: &mut Bencher) {
Expand Down Expand Up @@ -76,23 +82,21 @@ pub fn add_zip(xs: &[f32], ys: &mut [f32]) {
fn bench_zip_copy(b: &mut Bencher) {
let source = vec![0u8; 16 * 1024];
let mut dst = black_box(vec![0u8; 16 * 1024]);
b.iter(|| {
copy_zip(&source, &mut dst)
})
b.iter(|| copy_zip(&source, &mut dst))
}

#[bench]
fn bench_zip_add(b: &mut Bencher) {
let source = vec![1.; 16 * 1024];
let mut dst = vec![0.; 16 * 1024];
b.iter(|| {
add_zip(&source, &mut dst)
});
b.iter(|| add_zip(&source, &mut dst));
}

/// `Iterator::for_each` implemented as a plain loop.
fn for_each_loop<I, F>(iter: I, mut f: F) where
I: Iterator, F: FnMut(I::Item)
fn for_each_loop<I, F>(iter: I, mut f: F)
where
I: Iterator,
F: FnMut(I::Item),
{
for item in iter {
f(item);
Expand All @@ -101,8 +105,10 @@ fn for_each_loop<I, F>(iter: I, mut f: F) where

/// `Iterator::for_each` implemented with `fold` for internal iteration.
/// (except when `by_ref()` effectively disables that optimization.)
fn for_each_fold<I, F>(iter: I, mut f: F) where
I: Iterator, F: FnMut(I::Item)
fn for_each_fold<I, F>(iter: I, mut f: F)
where
I: Iterator,
F: FnMut(I::Item),
{
iter.fold((), move |(), item| f(item));
}
Expand Down Expand Up @@ -137,25 +143,20 @@ fn bench_for_each_chain_ref_fold(b: &mut Bencher) {
});
}


/// Helper to benchmark `sum` for iterators taken by value which
/// can optimize `fold`, and by reference which cannot.
macro_rules! bench_sums {
($bench_sum:ident, $bench_ref_sum:ident, $iter:expr) => {
#[bench]
fn $bench_sum(b: &mut Bencher) {
b.iter(|| -> i64 {
$iter.map(black_box).sum()
});
b.iter(|| -> i64 { $iter.map(black_box).sum() });
}

#[bench]
fn $bench_ref_sum(b: &mut Bencher) {
b.iter(|| -> i64 {
$iter.map(black_box).by_ref().sum()
});
b.iter(|| -> i64 { $iter.map(black_box).by_ref().sum() });
}
}
};
}

bench_sums! {
Expand Down Expand Up @@ -286,7 +287,10 @@ fn bench_zip_then_skip(b: &mut Bencher) {
let t: Vec<_> = (0..100_000).collect();

b.iter(|| {
let s = v.iter().zip(t.iter()).skip(10000)
let s = v
.iter()
.zip(t.iter())
.skip(10000)
.take_while(|t| *t.0 < 10100)
.map(|(a, b)| *a + *b)
.sum::<u64>();
Expand All @@ -299,7 +303,10 @@ fn bench_skip_then_zip(b: &mut Bencher) {
let t: Vec<_> = (0..100_000).collect();

b.iter(|| {
let s = v.iter().skip(10000).zip(t.iter().skip(10000))
let s = v
.iter()
.skip(10000)
.zip(t.iter().skip(10000))
.take_while(|t| *t.0 < 10100)
.map(|(a, b)| *a + *b)
.sum::<u64>();
Expand All @@ -309,23 +316,17 @@ fn bench_skip_then_zip(b: &mut Bencher) {

#[bench]
fn bench_filter_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count()
})
b.iter(|| (0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count())
}

#[bench]
fn bench_filter_ref_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
})
b.iter(|| (0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count())
}

#[bench]
fn bench_filter_chain_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count()
})
b.iter(|| (0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count())
}

#[bench]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ extern crate test;
mod any;
mod ascii;
mod char;
mod fmt;
mod hash;
mod iter;
mod num;
mod ops;
mod slice;
mod fmt;
Loading