Skip to content

Commit 7f5dc49

Browse files
committed
review or fix miri failures in iter, slice, cell, time
1 parent 26ade1c commit 7f5dc49

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

src/libcore/tests/cell.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use core::cell::*;
42
use core::default::Default;
53
use std::mem::drop;
@@ -111,6 +109,7 @@ fn double_borrow_single_release_no_borrow_mut() {
111109

112110
#[test]
113111
#[should_panic]
112+
#[cfg(not(miri))] // Miri does not support panics
114113
fn discard_doesnt_unborrow() {
115114
let x = RefCell::new(0);
116115
let _b = x.borrow();
@@ -351,6 +350,7 @@ fn refcell_ref_coercion() {
351350

352351
#[test]
353352
#[should_panic]
353+
#[cfg(not(miri))] // Miri does not support panics
354354
fn refcell_swap_borrows() {
355355
let x = RefCell::new(0);
356356
let _b = x.borrow();
@@ -360,6 +360,7 @@ fn refcell_swap_borrows() {
360360

361361
#[test]
362362
#[should_panic]
363+
#[cfg(not(miri))] // Miri does not support panics
363364
fn refcell_replace_borrows() {
364365
let x = RefCell::new(0);
365366
let _b = x.borrow();

src/libcore/tests/iter.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ fn test_iterator_step_by() {
190190
}
191191

192192
#[test]
193-
#[cfg(not(miri))]
194193
fn test_iterator_step_by_nth() {
195194
let mut it = (0..16).step_by(5);
196195
assert_eq!(it.nth(0), Some(0));
@@ -209,7 +208,6 @@ fn test_iterator_step_by_nth() {
209208
}
210209

211210
#[test]
212-
#[cfg(not(miri))]
213211
fn test_iterator_step_by_nth_overflow() {
214212
#[cfg(target_pointer_width = "8")]
215213
type Bigger = u16;
@@ -262,7 +260,6 @@ fn test_iterator_step_by_zero() {
262260
}
263261

264262
#[test]
265-
#[cfg(not(miri))]
266263
fn test_iterator_step_by_size_hint() {
267264
struct StubSizeHint(usize, Option<usize>);
268265
impl Iterator for StubSizeHint {
@@ -1657,15 +1654,16 @@ fn test_range_inclusive_nth() {
16571654
}
16581655

16591656
#[test]
1660-
#[cfg(not(miri))]
16611657
fn test_range_step() {
16621658
#![allow(deprecated)]
16631659

16641660
assert_eq!((0..20).step_by(5).collect::<Vec<isize>>(), [0, 5, 10, 15]);
16651661
assert_eq!((1..21).rev().step_by(5).collect::<Vec<isize>>(), [20, 15, 10, 5]);
16661662
assert_eq!((1..21).rev().step_by(6).collect::<Vec<isize>>(), [20, 14, 8, 2]);
16671663
assert_eq!((200..255).step_by(50).collect::<Vec<u8>>(), [200, 250]);
1664+
#[cfg(not(miri))] // Miri cannot compare empty slices
16681665
assert_eq!((200..-5).step_by(1).collect::<Vec<isize>>(), []);
1666+
#[cfg(not(miri))] // Miri cannot compare empty slices
16691667
assert_eq!((200..200).step_by(1).collect::<Vec<isize>>(), []);
16701668

16711669
assert_eq!((0..20).step_by(1).size_hint(), (20, Some(20)));
@@ -1681,15 +1679,13 @@ fn test_range_step() {
16811679
}
16821680

16831681
#[test]
1684-
#[cfg(not(miri))]
16851682
fn test_step_by_skip() {
16861683
assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]);
16871684
assert_eq!((0..=50).step_by(10).nth(3), Some(30));
16881685
assert_eq!((200..=255u8).step_by(10).nth(3), Some(230));
16891686
}
16901687

16911688
#[test]
1692-
#[cfg(not(miri))]
16931689
fn test_range_inclusive_step() {
16941690
assert_eq!((0..=50).step_by(10).collect::<Vec<_>>(), [0, 10, 20, 30, 40, 50]);
16951691
assert_eq!((0..=5).step_by(1).collect::<Vec<_>>(), [0, 1, 2, 3, 4, 5]);

src/libcore/tests/slice.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ fn test_rotate_right() {
10151015

10161016
#[test]
10171017
#[cfg(not(target_arch = "wasm32"))]
1018-
#[cfg(not(miri))]
1018+
#[cfg(not(miri))] // Miri does not support entropy
10191019
fn sort_unstable() {
10201020
use core::cmp::Ordering::{Equal, Greater, Less};
10211021
use core::slice::heapsort;
@@ -1171,7 +1171,7 @@ pub mod memchr {
11711171
}
11721172

11731173
#[test]
1174-
#[cfg(not(miri))]
1174+
#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation
11751175
fn test_align_to_simple() {
11761176
let bytes = [1u8, 2, 3, 4, 5, 6, 7];
11771177
let (prefix, aligned, suffix) = unsafe { bytes.align_to::<u16>() };
@@ -1187,7 +1187,6 @@ fn test_align_to_simple() {
11871187
}
11881188

11891189
#[test]
1190-
#[cfg(not(miri))]
11911190
fn test_align_to_zst() {
11921191
let bytes = [1, 2, 3, 4, 5, 6, 7];
11931192
let (prefix, aligned, suffix) = unsafe { bytes.align_to::<()>() };
@@ -1196,7 +1195,7 @@ fn test_align_to_zst() {
11961195
}
11971196

11981197
#[test]
1199-
#[cfg(not(miri))]
1198+
#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation
12001199
fn test_align_to_non_trivial() {
12011200
#[repr(align(8))] struct U64(u64, u64);
12021201
#[repr(align(8))] struct U64U64U32(u64, u64, u32);
@@ -1208,7 +1207,6 @@ fn test_align_to_non_trivial() {
12081207
}
12091208

12101209
#[test]
1211-
#[cfg(not(miri))]
12121210
fn test_align_to_empty_mid() {
12131211
use core::mem;
12141212

src/libcore/tests/time.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use core::time::Duration;
42

53
#[test]
@@ -109,12 +107,14 @@ fn checked_sub() {
109107

110108
#[test]
111109
#[should_panic]
110+
#[cfg(not(miri))] // Miri does not support panics
112111
fn sub_bad1() {
113112
let _ = Duration::new(0, 0) - Duration::new(0, 1);
114113
}
115114

116115
#[test]
117116
#[should_panic]
117+
#[cfg(not(miri))] // Miri does not support panics
118118
fn sub_bad2() {
119119
let _ = Duration::new(0, 0) - Duration::new(1, 0);
120120
}
@@ -287,6 +287,7 @@ fn debug_formatting_precision_two() {
287287
}
288288

289289
#[test]
290+
#[cfg(not(miri))] // FIXME: A bug in Miri breaks padding in string formatting
290291
fn debug_formatting_precision_high() {
291292
assert_eq!(format!("{:.5?}", Duration::new(0, 23_678)), "23.67800µs");
292293

0 commit comments

Comments
 (0)