Skip to content

Commit

Permalink
Rollup merge of rust-lang#91444 - RalfJung:miri-tests, r=dtolnay
Browse files Browse the repository at this point in the history
disable tests in Miri that take too long

Comparing slices of length `usize::MAX` diverges in Miri. In fact these tests even diverge in rustc unless `-O` is passed. I tried this code to check that:
```rust
#![feature(slice_take)]

const EMPTY_MAX: &'static [()] = &[(); usize::MAX];

fn main() {
    let mut slice: &[_] = &[(); usize::MAX];
    println!("1");
    assert_eq!(Some(&[] as _), slice.take(usize::MAX..));
    println!("2");
    let remaining: &[_] = EMPTY_MAX;
    println!("3");
    assert_eq!(remaining, slice);
    println!("4");
}
```
So, disable these tests in Miri for now.
  • Loading branch information
matthiaskrgr authored Dec 2, 2021
2 parents 816f2d6 + b11d880 commit 6054fa8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2330,13 +2330,15 @@ macro_rules! empty_max_mut {
};
}

#[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations)
take_tests! {
slice: &[(); usize::MAX], method: take,
(take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]),
(take_oob_max_range_to_inclusive, (..=usize::MAX), None, EMPTY_MAX),
(take_in_bounds_max_range_from, (usize::MAX..), Some(&[] as _), EMPTY_MAX),
}

#[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations)
take_tests! {
slice: &mut [(); usize::MAX], method: take_mut,
(take_mut_in_bounds_max_range_to, (..usize::MAX), Some(empty_max_mut!()), &mut [(); 0]),
Expand Down

0 comments on commit 6054fa8

Please sign in to comment.