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 11 pull requests #67184

Merged
merged 29 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
e9840d9
Print the visibility in `print_variant`.
Centril Dec 1, 2019
1b2a422
Simplify `check_decl_no_pat`.
Centril Dec 1, 2019
7ba1232
libcore: ignore tests in Miri instead of removing them entirely
RalfJung Dec 7, 2019
ca2ffe3
liballoc: ignore tests in Miri instead of removing them entirely
RalfJung Dec 7, 2019
ab73d10
fix warnings with cfg(miri)
RalfJung Dec 7, 2019
d97379a
Added ExactSizeIterator bound to return types
Dec 7, 2019
2b2b16c
Simplify `Layout::extend_packed`
kraai Dec 6, 2019
2468b23
fix miri step debug printing
RalfJung Dec 8, 2019
4ea7bb8
Move `Layout`s instead of binding by reference
kraai Dec 8, 2019
b879ecc
Do not ICE on closure
JohnTitor Dec 8, 2019
bf1f1c2
inline some common methods on OsStr
tesuji Dec 9, 2019
9e6725d
resolve: Resolve visibilities on fields with non-builtin attributes
petrochenkov Dec 6, 2019
e2c962d
resolve: Cleanup some field processing code
petrochenkov Dec 6, 2019
5f6267c
resolve: Make visibility resolution more speculative
petrochenkov Dec 6, 2019
989bf84
Added ExactSizeIterator bound to return types
Dec 9, 2019
4166ce8
Rollup merge of #66892 - dtolnay:fmt5, r=KodrAus
tmandry Dec 9, 2019
5c6941b
Rollup merge of #67106 - petrochenkov:docerr, r=matthewjasper
tmandry Dec 9, 2019
3340a5b
Rollup merge of #67113 - Centril:enum-vis-pretty-fix, r=davidtwco
tmandry Dec 9, 2019
a0e00f8
Rollup merge of #67115 - Centril:simplify-check-decl-no-pat, r=davidtwco
tmandry Dec 9, 2019
e775820
Rollup merge of #67119 - RalfJung:miri-test-libstd, r=alexcrichton
tmandry Dec 9, 2019
28b112f
Rollup merge of #67125 - hashedone:master, r=petrochenkov
tmandry Dec 9, 2019
6b6b6f3
Rollup merge of #67138 - kraai:simplify-Layout-extend_packed, r=Amanieu
tmandry Dec 9, 2019
5ce5464
Rollup merge of #67145 - RalfJung:miri-step, r=oli-obk
tmandry Dec 9, 2019
c2702e3
Rollup merge of #67149 - JohnTitor:fix-ice-1, r=Dylan-DPC
tmandry Dec 9, 2019
196ca9d
Rollup merge of #67155 - kraai:move-instead-of-binding-to-reference, …
tmandry Dec 9, 2019
c255815
Rollup merge of #67169 - lzutao:inline_osstr, r=nagisa
tmandry Dec 9, 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
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