Skip to content

Commit

Permalink
Auto merge of #67184 - tmandry:rollup-mzqxtck, r=tmandry
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #66892 (Format libcore with rustfmt (including tests and benches))
 - #67106 (resolve: Resolve visibilities on fields with non-builtin attributes)
 - #67113 (Print the visibility in `print_variant`.)
 - #67115 (Simplify `check_decl_no_pat`.)
 - #67119 (libstd miri tests: avoid warnings)
 - #67125 (Added ExactSizeIterator bound to return types)
 - #67138 (Simplify `Layout::extend_packed`)
 - #67145 (fix miri step debug printing)
 - #67149 (Do not ICE #67123)
 - #67155 (Move `Layout`s instead of binding by reference)
 - #67169 (inline some common methods on OsStr)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 10, 2019
2 parents 76a252e + c255815 commit 975e83a
Show file tree
Hide file tree
Showing 77 changed files with 1,587 additions and 1,321 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/alloc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn allocate_zeroed() {
}

#[bench]
#[cfg(not(miri))] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
fn alloc_owned_small(b: &mut Bencher) {
b.iter(|| {
let _: Box<_> = box 10;
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/linked_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn test_insert_prev() {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg(not(miri))] // Miri does not support threads
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn test_send() {
let n = list_from(&[1, 2, 3]);
thread::spawn(move || {
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
use ::test;

#[bench]
#[cfg(not(miri))] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
fn bench_push_back_100(b: &mut test::Bencher) {
let mut deq = VecDeque::with_capacity(101);
b.iter(|| {
Expand All @@ -16,7 +16,7 @@ fn bench_push_back_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg(not(miri))] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
fn bench_push_front_100(b: &mut test::Bencher) {
let mut deq = VecDeque::with_capacity(101);
b.iter(|| {
Expand All @@ -29,7 +29,7 @@ fn bench_push_front_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg(not(miri))] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
fn bench_pop_back_100(b: &mut test::Bencher) {
let mut deq = VecDeque::<i32>::with_capacity(101);

Expand All @@ -43,7 +43,7 @@ fn bench_pop_back_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg(not(miri))] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
fn bench_pop_front_100(b: &mut test::Bencher) {
let mut deq = VecDeque::<i32>::with_capacity(101);

Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/sync/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Drop for Canary {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg(not(miri))] // Miri does not support threads
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn manually_share_arc() {
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = Arc::new(v);
Expand Down Expand Up @@ -334,7 +334,7 @@ fn test_ptr_eq() {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg(not(miri))] // Miri does not support threads
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn test_weak_count_locked() {
let mut a = Arc::new(atomic::AtomicBool::new(false));
let a2 = a.clone();
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ fn test_reverse() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_sort() {
let mut rng = thread_rng();

Expand Down Expand Up @@ -1610,7 +1610,7 @@ fn panic_safe() {
let moduli = &[5, 20, 50];

#[cfg(miri)]
let lens = (1..13);
let lens = 1..13;
#[cfg(miri)]
let moduli = &[10];

Expand Down
15 changes: 7 additions & 8 deletions src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_unsafe_slice() {
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
Expand Down Expand Up @@ -483,8 +483,8 @@ mod slice_index {
}

#[test]
#[cfg(not(target_os = "emscripten"))] // hits an OOM
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM
#[cfg_attr(miri, ignore)] // Miri is too slow
fn simple_big() {
fn a_million_letter_x() -> String {
let mut i = 0;
Expand Down Expand Up @@ -1069,7 +1069,7 @@ fn test_rev_iterator() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_chars_decoding() {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(std::char::from_u32) {
Expand All @@ -1081,7 +1081,7 @@ fn test_chars_decoding() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_chars_rev_decoding() {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(std::char::from_u32) {
Expand Down Expand Up @@ -1380,7 +1380,6 @@ fn test_bool_from_str() {
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
}

#[cfg(not(miri))] // Miri is too slow
fn check_contains_all_substrings(s: &str) {
assert!(s.contains(""));
for i in 0..s.len() {
Expand All @@ -1391,7 +1390,7 @@ fn check_contains_all_substrings(s: &str) {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn strslice_issue_16589() {
assert!("bananas".contains("nana"));

Expand All @@ -1408,7 +1407,7 @@ fn strslice_issue_16878() {


#[test]
#[cfg(not(miri))] // Miri is too slow
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_strslice_contains() {
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
check_contains_all_substrings(x);
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ fn test_reserve_exact() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve() {

// These are the interesting cases:
Expand Down Expand Up @@ -601,7 +601,7 @@ fn test_try_reserve() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve_exact() {

// This is exactly the same as test_try_reserve with the method changed.
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ fn test_reserve_exact() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve() {

// These are the interesting cases:
Expand Down Expand Up @@ -1183,7 +1183,7 @@ fn test_try_reserve() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve_exact() {

// This is exactly the same as test_try_reserve with the method changed.
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/tests/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ fn test_reserve_exact_2() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve() {
// These are the interesting cases:
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
Expand Down Expand Up @@ -1214,7 +1214,7 @@ fn test_try_reserve() {
}

#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.
// See that test for comments.
Expand Down
15 changes: 7 additions & 8 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ impl Layout {
pub fn extend_packed(&self, next: Self) -> Result<Self, LayoutErr> {
let new_size = self.size().checked_add(next.size())
.ok_or(LayoutErr { private: () })?;
let layout = Layout::from_size_align(new_size, self.align())?;
Ok(layout)
Layout::from_size_align(new_size, self.align())
}

/// Creates a layout describing the record for a `[T; n]`.
Expand Down Expand Up @@ -1143,9 +1142,9 @@ pub unsafe trait Alloc {
where Self: Sized
{
match Layout::array::<T>(n) {
Ok(ref layout) if layout.size() > 0 => {
Ok(layout) if layout.size() > 0 => {
unsafe {
self.alloc(layout.clone()).map(|p| p.cast())
self.alloc(layout).map(|p| p.cast())
}
}
_ => Err(AllocErr),
Expand Down Expand Up @@ -1193,9 +1192,9 @@ pub unsafe trait Alloc {
where Self: Sized
{
match (Layout::array::<T>(n_old), Layout::array::<T>(n_new)) {
(Ok(ref k_old), Ok(ref k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
(Ok(k_old), Ok(k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
debug_assert!(k_old.align() == k_new.align());
self.realloc(ptr.cast(), k_old.clone(), k_new.size()).map(NonNull::cast)
self.realloc(ptr.cast(), k_old, k_new.size()).map(NonNull::cast)
}
_ => {
Err(AllocErr)
Expand Down Expand Up @@ -1227,8 +1226,8 @@ pub unsafe trait Alloc {
where Self: Sized
{
match Layout::array::<T>(n) {
Ok(ref k) if k.size() > 0 => {
Ok(self.dealloc(ptr.cast(), k.clone()))
Ok(k) if k.size() > 0 => {
Ok(self.dealloc(ptr.cast(), k))
}
_ => {
Err(AllocErr)
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
Loading

0 comments on commit 975e83a

Please sign in to comment.