Skip to content

Rollup of 5 pull requests #71509

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

Merged
merged 18 commits into from
Apr 24, 2020
Merged
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions src/liballoc/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
@@ -386,10 +386,8 @@ fn test_vec_from_vecdeque() {
assert!(vec.into_iter().eq(vd));
}

#[cfg(not(miri))] // Miri is too slow
let max_pwr = 7;
#[cfg(miri)]
let max_pwr = 5;
// Miri is too slow
let max_pwr = if cfg!(miri) { 5 } else { 7 };

for cap_pwr in 0..max_pwr {
// Make capacity as a (2^x)-1, so that the ring size is 2^x
8 changes: 3 additions & 5 deletions src/liballoc/tests/binary_heap.rs
Original file line number Diff line number Diff line change
@@ -409,16 +409,14 @@ fn panic_safe() {
}
let mut rng = thread_rng();
const DATASZ: usize = 32;
#[cfg(not(miri))] // Miri is too slow
const NTEST: usize = 10;
#[cfg(miri)]
const NTEST: usize = 1;
// Miri is too slow
let ntest = if cfg!(miri) { 1 } else { 10 };

// don't use 0 in the data -- we want to catch the zeroed-out case.
let data = (1..=DATASZ).collect::<Vec<_>>();

// since it's a fuzzy test, run several tries.
for _ in 0..NTEST {
for _ in 0..ntest {
for i in 1..=DATASZ {
DROP_COUNTER.store(0, Ordering::SeqCst);

48 changes: 16 additions & 32 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
@@ -28,10 +28,8 @@ const MIN_INSERTS_HEIGHT_2: usize = NODE_CAPACITY + (NODE_CAPACITY + 1) * NODE_C
#[test]
fn test_basic_large() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = MIN_INSERTS_HEIGHT_2;
// Miri is too slow
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 } else { 10000 };
assert_eq!(map.len(), 0);

for i in 0..size {
@@ -155,10 +153,8 @@ fn test_basic_small() {

#[test]
fn test_iter() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };

let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

@@ -180,10 +176,8 @@ fn test_iter() {

#[test]
fn test_iter_rev() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };

let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

@@ -289,10 +283,8 @@ fn test_values_mut() {

#[test]
fn test_iter_mixed() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };

let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

@@ -525,10 +517,8 @@ fn test_range_backwards_4() {

#[test]
fn test_range_1000() {
#[cfg(not(miri))] // Miri is too slow
let size = 1000;
#[cfg(miri)]
let size = MIN_INSERTS_HEIGHT_2 as u32;
// Miri is too slow
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 as u32 } else { 1000 };
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
@@ -566,10 +556,8 @@ fn test_range_borrowed_key() {
#[test]
fn test_range() {
let size = 200;
#[cfg(not(miri))] // Miri is too slow
let step = 1;
#[cfg(miri)]
let step = 66;
// Miri is too slow
let step = if cfg!(miri) { 66 } else { 1 };
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

for i in (0..size).step_by(step) {
@@ -589,10 +577,8 @@ fn test_range() {
#[test]
fn test_range_mut() {
let size = 200;
#[cfg(not(miri))] // Miri is too slow
let step = 1;
#[cfg(miri)]
let step = 66;
// Miri is too slow
let step = if cfg!(miri) { 66 } else { 1 };
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();

for i in (0..size).step_by(step) {
@@ -1263,10 +1249,8 @@ fn test_split_off_empty_left() {

#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// Miri is too slow
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
// special case with maximum height.
data.sort();

6 changes: 2 additions & 4 deletions src/liballoc/tests/btree/set.rs
Original file line number Diff line number Diff line change
@@ -621,10 +621,8 @@ fn test_split_off_empty_left() {

#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// Miri is too slow
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
// special case with maximum height.
data.sort();

24 changes: 6 additions & 18 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
@@ -463,15 +463,9 @@ fn test_sort() {

#[test]
fn test_sort_stability() {
#[cfg(not(miri))] // Miri is too slow
let large_range = 500..510;
#[cfg(not(miri))] // Miri is too slow
let rounds = 10;

#[cfg(miri)]
let large_range = 0..0; // empty range
#[cfg(miri)]
let rounds = 1;
// Miri is too slow
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
let rounds = if cfg!(miri) { 1 } else { 10 };

for len in (2..25).chain(large_range) {
for _ in 0..rounds {
@@ -1727,15 +1721,9 @@ fn panic_safe() {

let mut rng = thread_rng();

#[cfg(not(miri))] // Miri is too slow
let lens = (1..20).chain(70..MAX_LEN);
#[cfg(not(miri))] // Miri is too slow
let moduli = &[5, 20, 50];

#[cfg(miri)]
let lens = 1..10;
#[cfg(miri)]
let moduli = &[5];
// Miri is too slow
let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) };
let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] };

for len in lens {
for &modulus in moduli {
14 changes: 6 additions & 8 deletions src/liballoc/tests/vec_deque.rs
Original file line number Diff line number Diff line change
@@ -954,16 +954,14 @@ fn test_append_permutations() {
out
}

#[cfg(not(miri))] // Miri is too slow
const MAX: usize = 5;
#[cfg(miri)]
const MAX: usize = 3;
// Miri is too slow
let max = if cfg!(miri) { 3 } else { 5 };

// Many different permutations of both the `VecDeque` getting appended to
// and the one getting appended are generated to check `append`.
// This ensures all 6 code paths of `append` are tested.
for src_push_back in 0..MAX {
for src_push_front in 0..MAX {
for src_push_back in 0..max {
for src_push_front in 0..max {
// doesn't pop more values than are pushed
for src_pop_back in 0..(src_push_back + src_push_front) {
for src_pop_front in 0..(src_push_back + src_push_front - src_pop_back) {
@@ -974,8 +972,8 @@ fn test_append_permutations() {
src_pop_front,
);

for dst_push_back in 0..MAX {
for dst_push_front in 0..MAX {
for dst_push_back in 0..max {
for dst_push_front in 0..max {
for dst_pop_back in 0..(dst_push_back + dst_push_front) {
for dst_pop_front in
0..(dst_push_back + dst_push_front - dst_pop_back)
8 changes: 3 additions & 5 deletions src/libcore/tests/num/flt2dec/estimator.rs
Original file line number Diff line number Diff line change
@@ -52,12 +52,10 @@ fn test_estimate_scaling_factor() {
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);

#[cfg(not(miri))] // Miri is too slow
let iter = -1074..972;
#[cfg(miri)]
let iter = (-1074..972).step_by(37);
// Miri is too slow
let step = if cfg!(miri) { 37 } else { 1 };

for i in iter {
for i in (-1074..972).step_by(step) {
let expected = super::ldexp_f64(1.0, i).log10().ceil();
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
}
26 changes: 10 additions & 16 deletions src/libcore/tests/num/flt2dec/random.rs
Original file line number Diff line number Diff line change
@@ -138,13 +138,11 @@ where
#[test]
fn shortest_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 10_000;
#[cfg(miri)]
const N: usize = 10;
// Miri is too slow
let n = if cfg!(miri) { 10 } else { 10_000 };

f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, n);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, n);
}

#[test]
@@ -173,35 +171,31 @@ fn shortest_f64_hard_random_equivalence_test() {
#[test]
fn exact_f32_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;
// Miri is too slow
let n = if cfg!(miri) { 3 } else { 1_000 };

for k in 1..21 {
f32_random_equivalence_test(
|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN),
k,
N,
n,
);
}
}

#[test]
fn exact_f64_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;
// Miri is too slow
let n = if cfg!(miri) { 3 } else { 1_000 };

for k in 1..21 {
f64_random_equivalence_test(
|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN),
k,
N,
n,
);
}
}
12 changes: 3 additions & 9 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
@@ -1227,15 +1227,9 @@ fn sort_unstable() {
use core::slice::heapsort;
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};

#[cfg(not(miri))] // Miri is too slow
let large_range = 500..510;
#[cfg(not(miri))] // Miri is too slow
let rounds = 100;

#[cfg(miri)]
let large_range = 0..0; // empty range
#[cfg(miri)]
let rounds = 1;
// Miri is too slow
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
let rounds = if cfg!(miri) { 1 } else { 100 };

let mut v = [0; 600];
let mut tmp = [0; 600];
5 changes: 4 additions & 1 deletion src/librustc_ast_lowering/path.rs
Original file line number Diff line number Diff line change
@@ -273,7 +273,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.next();
if !generic_args.parenthesized && !has_lifetimes {
generic_args.args = self
.elided_path_lifetimes(path_span, expected_lifetimes)
.elided_path_lifetimes(
first_generic_span.map(|s| s.shrink_to_lo()).unwrap_or(segment.ident.span),
expected_lifetimes,
)
.map(GenericArg::Lifetime)
.chain(generic_args.args.into_iter())
.collect();
Loading