Skip to content

Commit 767dadf

Browse files
committed
review failures in heap, slice, vec
1 parent 4c1a1c3 commit 767dadf

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/liballoc/tests/heap.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::alloc::{Global, Alloc, Layout, System};
42

53
/// Issue #45955.

src/liballoc/tests/slice.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::cell::Cell;
42
use std::cmp::Ordering::{self, Equal, Greater, Less};
53
use std::mem;
@@ -260,6 +258,7 @@ fn test_swap_remove() {
260258

261259
#[test]
262260
#[should_panic]
261+
#[cfg(not(miri))] // Miri does not support panics
263262
fn test_swap_remove_fail() {
264263
let mut v = vec![1];
265264
let _ = v.swap_remove(0);
@@ -391,6 +390,7 @@ fn test_reverse() {
391390
}
392391

393392
#[test]
393+
#[cfg(not(miri))] // Miri does not support entropy
394394
fn test_sort() {
395395
let mut rng = thread_rng();
396396

@@ -467,6 +467,7 @@ fn test_sort() {
467467
}
468468

469469
#[test]
470+
#[cfg(not(miri))] // Miri does not support entropy
470471
fn test_sort_stability() {
471472
for len in (2..25).chain(500..510) {
472473
for _ in 0..10 {
@@ -631,6 +632,7 @@ fn test_insert() {
631632

632633
#[test]
633634
#[should_panic]
635+
#[cfg(not(miri))] // Miri does not support panics
634636
fn test_insert_oob() {
635637
let mut a = vec![1, 2, 3];
636638
a.insert(4, 5);
@@ -655,6 +657,7 @@ fn test_remove() {
655657

656658
#[test]
657659
#[should_panic]
660+
#[cfg(not(miri))] // Miri does not support panics
658661
fn test_remove_fail() {
659662
let mut a = vec![1];
660663
let _ = a.remove(0);
@@ -936,6 +939,7 @@ fn test_windowsator() {
936939

937940
#[test]
938941
#[should_panic]
942+
#[cfg(not(miri))] // Miri does not support panics
939943
fn test_windowsator_0() {
940944
let v = &[1, 2, 3, 4];
941945
let _it = v.windows(0);
@@ -960,6 +964,7 @@ fn test_chunksator() {
960964

961965
#[test]
962966
#[should_panic]
967+
#[cfg(not(miri))] // Miri does not support panics
963968
fn test_chunksator_0() {
964969
let v = &[1, 2, 3, 4];
965970
let _it = v.chunks(0);
@@ -984,6 +989,7 @@ fn test_chunks_exactator() {
984989

985990
#[test]
986991
#[should_panic]
992+
#[cfg(not(miri))] // Miri does not support panics
987993
fn test_chunks_exactator_0() {
988994
let v = &[1, 2, 3, 4];
989995
let _it = v.chunks_exact(0);
@@ -1008,6 +1014,7 @@ fn test_rchunksator() {
10081014

10091015
#[test]
10101016
#[should_panic]
1017+
#[cfg(not(miri))] // Miri does not support panics
10111018
fn test_rchunksator_0() {
10121019
let v = &[1, 2, 3, 4];
10131020
let _it = v.rchunks(0);
@@ -1032,6 +1039,7 @@ fn test_rchunks_exactator() {
10321039

10331040
#[test]
10341041
#[should_panic]
1042+
#[cfg(not(miri))] // Miri does not support panics
10351043
fn test_rchunks_exactator_0() {
10361044
let v = &[1, 2, 3, 4];
10371045
let _it = v.rchunks_exact(0);
@@ -1084,6 +1092,7 @@ fn test_vec_default() {
10841092

10851093
#[test]
10861094
#[should_panic]
1095+
#[cfg(not(miri))] // Miri does not support panics
10871096
fn test_overflow_does_not_cause_segfault() {
10881097
let mut v = vec![];
10891098
v.reserve_exact(!0);
@@ -1093,6 +1102,7 @@ fn test_overflow_does_not_cause_segfault() {
10931102

10941103
#[test]
10951104
#[should_panic]
1105+
#[cfg(not(miri))] // Miri does not support panics
10961106
fn test_overflow_does_not_cause_segfault_managed() {
10971107
let mut v = vec![Rc::new(1)];
10981108
v.reserve_exact(!0);
@@ -1268,6 +1278,7 @@ fn test_mut_chunks_rev() {
12681278

12691279
#[test]
12701280
#[should_panic]
1281+
#[cfg(not(miri))] // Miri does not support panics
12711282
fn test_mut_chunks_0() {
12721283
let mut v = [1, 2, 3, 4];
12731284
let _it = v.chunks_mut(0);
@@ -1300,6 +1311,7 @@ fn test_mut_chunks_exact_rev() {
13001311

13011312
#[test]
13021313
#[should_panic]
1314+
#[cfg(not(miri))] // Miri does not support panics
13031315
fn test_mut_chunks_exact_0() {
13041316
let mut v = [1, 2, 3, 4];
13051317
let _it = v.chunks_exact_mut(0);
@@ -1332,6 +1344,7 @@ fn test_mut_rchunks_rev() {
13321344

13331345
#[test]
13341346
#[should_panic]
1347+
#[cfg(not(miri))] // Miri does not support panics
13351348
fn test_mut_rchunks_0() {
13361349
let mut v = [1, 2, 3, 4];
13371350
let _it = v.rchunks_mut(0);
@@ -1364,6 +1377,7 @@ fn test_mut_rchunks_exact_rev() {
13641377

13651378
#[test]
13661379
#[should_panic]
1380+
#[cfg(not(miri))] // Miri does not support panics
13671381
fn test_mut_rchunks_exact_0() {
13681382
let mut v = [1, 2, 3, 4];
13691383
let _it = v.rchunks_exact_mut(0);
@@ -1397,6 +1411,7 @@ fn test_box_slice_clone() {
13971411
#[test]
13981412
#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
13991413
#[cfg_attr(target_os = "emscripten", ignore)]
1414+
#[cfg(not(miri))] // Miri does not support panics
14001415
fn test_box_slice_clone_panics() {
14011416
use std::sync::Arc;
14021417
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -1461,6 +1476,7 @@ fn test_copy_from_slice() {
14611476

14621477
#[test]
14631478
#[should_panic(expected = "destination and source slices have different lengths")]
1479+
#[cfg(not(miri))] // Miri does not support panics
14641480
fn test_copy_from_slice_dst_longer() {
14651481
let src = [0, 1, 2, 3];
14661482
let mut dst = [0; 5];
@@ -1469,6 +1485,7 @@ fn test_copy_from_slice_dst_longer() {
14691485

14701486
#[test]
14711487
#[should_panic(expected = "destination and source slices have different lengths")]
1488+
#[cfg(not(miri))] // Miri does not support panics
14721489
fn test_copy_from_slice_dst_shorter() {
14731490
let src = [0, 1, 2, 3];
14741491
let mut dst = [0; 3];
@@ -1588,6 +1605,7 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
15881605

15891606
#[test]
15901607
#[cfg_attr(target_os = "emscripten", ignore)] // no threads
1608+
#[cfg(not(miri))] // Miri does not support panics
15911609
fn panic_safe() {
15921610
let prev = panic::take_hook();
15931611
panic::set_hook(Box::new(move |info| {

src/liballoc/tests/vec.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ fn test_vec_truncate_drop() {
368368

369369
#[test]
370370
#[should_panic]
371+
#[cfg(not(miri))] // Miri does not support panics
371372
fn test_vec_truncate_fail() {
372373
struct BadElem(i32);
373374
impl Drop for BadElem {
@@ -391,48 +392,55 @@ fn test_index() {
391392

392393
#[test]
393394
#[should_panic]
395+
#[cfg(not(miri))] // Miri does not support panics
394396
fn test_index_out_of_bounds() {
395397
let vec = vec![1, 2, 3];
396398
let _ = vec[3];
397399
}
398400

399401
#[test]
400402
#[should_panic]
403+
#[cfg(not(miri))] // Miri does not support panics
401404
fn test_slice_out_of_bounds_1() {
402405
let x = vec![1, 2, 3, 4, 5];
403406
&x[!0..];
404407
}
405408

406409
#[test]
407410
#[should_panic]
411+
#[cfg(not(miri))] // Miri does not support panics
408412
fn test_slice_out_of_bounds_2() {
409413
let x = vec![1, 2, 3, 4, 5];
410414
&x[..6];
411415
}
412416

413417
#[test]
414418
#[should_panic]
419+
#[cfg(not(miri))] // Miri does not support panics
415420
fn test_slice_out_of_bounds_3() {
416421
let x = vec![1, 2, 3, 4, 5];
417422
&x[!0..4];
418423
}
419424

420425
#[test]
421426
#[should_panic]
427+
#[cfg(not(miri))] // Miri does not support panics
422428
fn test_slice_out_of_bounds_4() {
423429
let x = vec![1, 2, 3, 4, 5];
424430
&x[1..6];
425431
}
426432

427433
#[test]
428434
#[should_panic]
435+
#[cfg(not(miri))] // Miri does not support panics
429436
fn test_slice_out_of_bounds_5() {
430437
let x = vec![1, 2, 3, 4, 5];
431438
&x[3..2];
432439
}
433440

434441
#[test]
435442
#[should_panic]
443+
#[cfg(not(miri))] // Miri does not support panics
436444
fn test_swap_remove_empty() {
437445
let mut vec = Vec::<i32>::new();
438446
vec.swap_remove(0);
@@ -503,6 +511,7 @@ fn test_drain_items_zero_sized() {
503511

504512
#[test]
505513
#[should_panic]
514+
#[cfg(not(miri))] // Miri does not support panics
506515
fn test_drain_out_of_bounds() {
507516
let mut v = vec![1, 2, 3, 4, 5];
508517
v.drain(5..6);
@@ -576,6 +585,7 @@ fn test_drain_max_vec_size() {
576585

577586
#[test]
578587
#[should_panic]
588+
#[cfg(not(miri))] // Miri does not support panics
579589
fn test_drain_inclusive_out_of_bounds() {
580590
let mut v = vec![1, 2, 3, 4, 5];
581591
v.drain(5..=5);
@@ -605,6 +615,7 @@ fn test_splice_inclusive_range() {
605615

606616
#[test]
607617
#[should_panic]
618+
#[cfg(not(miri))] // Miri does not support panics
608619
fn test_splice_out_of_bounds() {
609620
let mut v = vec![1, 2, 3, 4, 5];
610621
let a = [10, 11, 12];
@@ -613,6 +624,7 @@ fn test_splice_out_of_bounds() {
613624

614625
#[test]
615626
#[should_panic]
627+
#[cfg(not(miri))] // Miri does not support panics
616628
fn test_splice_inclusive_out_of_bounds() {
617629
let mut v = vec![1, 2, 3, 4, 5];
618630
let a = [10, 11, 12];

0 commit comments

Comments
 (0)