From: Ralf Jung Date: Wed, 13 Feb 2019 12:59:51 +0000 (+0100) Subject: review failures in binary_heap, str, vec_deque X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b17ca0107755f60a1760f1dca17240cd70d15c5f;p=rust.git review failures in binary_heap, str, vec_deque --- diff --git a/src/liballoc/tests/arc.rs b/src/liballoc/tests/arc.rs index 7c5a8926126..2759b1b1cac 100644 --- a/src/liballoc/tests/arc.rs +++ b/src/liballoc/tests/arc.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::any::Any; use std::sync::{Arc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index c1a1c5d8878..1d4a3edc1ac 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -282,7 +282,7 @@ fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { // // Destructors must be called exactly once per element. #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn panic_safe() { static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); diff --git a/src/liballoc/tests/rc.rs b/src/liballoc/tests/rc.rs index 1be01d1a7ce..18f82e80410 100644 --- a/src/liballoc/tests/rc.rs +++ b/src/liballoc/tests/rc.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::any::Any; use std::rc::{Rc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index a1dc763f6d8..b33a5642188 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -31,7 +31,6 @@ fn test_rfind() { } #[test] -#[cfg(not(miri))] fn test_collect() { let empty = ""; let s: String = empty.chars().collect(); @@ -119,7 +118,6 @@ fn test_concat_for_different_types() { #[test] fn test_concat_for_different_lengths() { let empty: &[&str] = &[]; - #[cfg(not(miri))] test_concat!("", empty); test_concat!("a", ["a"]); test_concat!("ab", ["a", "b"]); @@ -148,7 +146,6 @@ fn test_join_for_different_types() { #[test] fn test_join_for_different_lengths() { let empty: &[&str] = &[]; - #[cfg(not(miri))] test_join!("", empty, "-"); test_join!("a", ["a"], "-"); test_join!("a-b", ["a", "b"], "-"); @@ -162,7 +159,6 @@ fn test_join_for_different_lengths_with_long_separator() { assert_eq!("~~~~~".len(), 15); let empty: &[&str] = &[]; - #[cfg(not(miri))] test_join!("", empty, "~~~~~"); test_join!("a", ["a"], "~~~~~"); test_join!("a~~~~~b", ["a", "b"], "~~~~~"); @@ -170,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // 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)}); @@ -243,7 +239,6 @@ fn test_replacen() { #[test] fn test_replace() { let a = "a"; - #[cfg(not(miri))] assert_eq!("".replace(a, "b"), ""); assert_eq!("a".replace(a, "b"), "b"); assert_eq!("ab".replace(a, "b"), "bb"); @@ -303,7 +298,6 @@ fn test_replace_pattern() { // The current implementation of SliceIndex fails to handle methods // orthogonally from range types; therefore, it is worth testing // all of the indexing operations on each input. -#[cfg(not(miri))] mod slice_index { // Test a slicing operation **that should succeed,** // testing it on all of the indexing methods. @@ -357,6 +351,7 @@ macro_rules! assert_range_eq { // to be used in `should_panic`) #[test] #[should_panic(expected = "out of bounds")] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_panic() { assert_range_eq!("abc", 0..5, "abc"); } @@ -366,6 +361,7 @@ fn assert_range_eq_can_fail_by_panic() { // to be used in `should_panic`) #[test] #[should_panic(expected = "==")] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_inequality() { assert_range_eq!("abc", 0..2, "abc"); } @@ -413,6 +409,7 @@ fn pass() { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] // Miri does not support panics fn index_fail() { let v: String = $data.into(); let v: &str = &v; @@ -421,6 +418,7 @@ fn index_fail() { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] // Miri does not support panics fn index_mut_fail() { let mut v: String = $data.into(); let v: &mut str = &mut v; @@ -490,6 +488,7 @@ fn simple_unicode() { #[test] #[cfg(not(target_arch = "asmjs"))] // hits an OOM + #[cfg(not(miri))] // Miri is too slow fn simple_big() { fn a_million_letter_x() -> String { let mut i = 0; @@ -515,6 +514,7 @@ fn half_a_million_letter_x() -> String { #[test] #[should_panic] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail() { &"中华Việt Nam"[0..2]; } @@ -666,12 +666,14 @@ mod boundary { // check the panic includes the prefix of the sliced string #[test] #[should_panic(expected="byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail_truncated_1() { &LOREM_PARAGRAPH[..1024]; } // check the truncation in the panic message #[test] #[should_panic(expected="luctus, im`[...]")] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail_truncated_2() { &LOREM_PARAGRAPH[..1024]; } @@ -686,7 +688,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; &s[..=3]; @@ -702,7 +704,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; @@ -892,7 +894,7 @@ fn test_as_bytes() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_as_bytes_fail() { // Don't double free. (I'm not sure if this exercises the // original problem code path anymore.) @@ -982,7 +984,7 @@ fn test_split_at_mut() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_split_at_boundscheck() { let s = "ศไทย中华Việt Nam"; s.split_at(1); @@ -1078,7 +1080,7 @@ fn test_rev_iterator() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_chars_decoding() { let mut bytes = [0; 4]; for c in (0..0x110000).filter_map(std::char::from_u32) { @@ -1090,7 +1092,7 @@ fn test_chars_decoding() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // 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) { @@ -1320,7 +1322,6 @@ fn t(s: &str, sep: &str, u: &[&str]) { } #[test] -#[cfg(not(miri))] fn test_str_default() { use std::default::Default; @@ -1380,7 +1381,7 @@ fn test_bool_from_str() { assert_eq!("not even a boolean".parse::().ok(), None); } -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn check_contains_all_substrings(s: &str) { assert!(s.contains("")); for i in 0..s.len() { @@ -1391,7 +1392,7 @@ fn check_contains_all_substrings(s: &str) { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn strslice_issue_16589() { assert!("bananas".contains("nana")); @@ -1401,7 +1402,6 @@ fn strslice_issue_16589() { } #[test] -#[cfg(not(miri))] fn strslice_issue_16878() { assert!(!"1234567ah012345678901ah".contains("hah")); assert!(!"00abc01234567890123456789abc".contains("bcabc")); @@ -1409,7 +1409,7 @@ fn strslice_issue_16878() { #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // 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); @@ -1547,7 +1547,6 @@ fn trim_ws() { #[test] fn to_lowercase() { - #[cfg(not(miri))] assert_eq!("".to_lowercase(), ""); assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé "); @@ -1581,7 +1580,6 @@ fn to_lowercase() { #[test] fn to_uppercase() { - #[cfg(not(miri))] assert_eq!("".to_uppercase(), ""); assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ"); } @@ -1613,7 +1611,6 @@ fn test_cow_from() { } #[test] -#[cfg(not(miri))] fn test_repeat() { assert_eq!("".repeat(3), ""); assert_eq!("abc".repeat(0), ""); diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index b47e7c867e6..d3439fed3cf 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -108,7 +108,7 @@ fn test_index() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_index_out_of_bounds() { let mut deq = VecDeque::new(); for i in 1..4 { @@ -907,24 +907,21 @@ fn test_append() { // normal append a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append nothing to something a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append something to nothing b.append(&mut a); assert_eq!(b.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(a.iter().cloned().collect::>(), []); } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_append_permutations() { fn construct_vec_deque( push_back: usize, @@ -1125,7 +1122,7 @@ fn test_reserve_exact_2() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve() { // These are the interesting cases: @@ -1227,7 +1224,7 @@ fn test_try_reserve() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve_exact() { // This is exactly the same as test_try_reserve with the method changed.