diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-30 14:33:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-30 14:33:48 +0200 |
| commit | 0ed320bdb9dff0f26f682cd6c9ccd6bfbffe5df8 (patch) | |
| tree | b2aa9546006a30e5d1ae2c9dc1e03b1dc2df6340 /library/alloc/tests | |
| parent | 5c780b98d10f48d6255cf2deb2643194b9221c02 (diff) | |
| parent | cdb8e64bc78400f9366db3b556bb01f470855f55 (diff) | |
Rollup merge of #97494 - est31:remove_box_alloc_tests, r=Dylan-DPC
Use Box::new() instead of box syntax in library tests The tests inside `library/*` have no reason to use `box` syntax as they have 0 performance relevance. Therefore, we can safely remove them (instead of having to use alternatives like the one in #97293).
Diffstat (limited to 'library/alloc/tests')
| -rw-r--r-- | library/alloc/tests/slice.rs | 14 | ||||
| -rw-r--r-- | library/alloc/tests/vec.rs | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index b027a25a146..21f894343be 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -268,9 +268,9 @@ fn test_swap_remove_fail() { fn test_swap_remove_noncopyable() { // Tests that we don't accidentally run destructors twice. let mut v: Vec<Box<_>> = Vec::new(); - v.push(box 0); - v.push(box 0); - v.push(box 0); + v.push(Box::new(0)); + v.push(Box::new(0)); + v.push(Box::new(0)); let mut _e = v.swap_remove(0); assert_eq!(v.len(), 2); _e = v.swap_remove(1); @@ -296,7 +296,7 @@ fn test_push() { #[test] fn test_truncate() { - let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4]; + let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)]; v.truncate(1); let v = v; assert_eq!(v.len(), 1); @@ -306,7 +306,7 @@ fn test_truncate() { #[test] fn test_clear() { - let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4]; + let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)]; v.clear(); assert_eq!(v.len(), 0); // If the unsafe block didn't drop things properly, we blow up here. @@ -1516,14 +1516,14 @@ fn test_mut_last() { #[test] fn test_to_vec() { - let xs: Box<_> = box [1, 2, 3]; + let xs: Box<_> = Box::new([1, 2, 3]); let ys = xs.to_vec(); assert_eq!(ys, [1, 2, 3]); } #[test] fn test_in_place_iterator_specialization() { - let src: Box<[usize]> = box [1, 2, 3]; + let src: Box<[usize]> = Box::new([1, 2, 3]); let src_ptr = src.as_ptr(); let sink: Box<_> = src.into_vec().into_iter().map(std::convert::identity).collect(); let sink_ptr = sink.as_ptr(); diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index bc1397146dd..cc768c73c0e 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -266,8 +266,8 @@ fn test_clone() { #[test] fn test_clone_from() { let mut v = vec![]; - let three: Vec<Box<_>> = vec![box 1, box 2, box 3]; - let two: Vec<Box<_>> = vec![box 4, box 5]; + let three: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(3)]; + let two: Vec<Box<_>> = vec![Box::new(4), Box::new(5)]; // zero, long v.clone_from(&three); assert_eq!(v, three); @@ -407,11 +407,11 @@ fn test_dedup_by() { #[test] fn test_dedup_unique() { - let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3]; + let mut v0: Vec<Box<_>> = vec![Box::new(1), Box::new(1), Box::new(2), Box::new(3)]; v0.dedup(); - let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3]; + let mut v1: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(2), Box::new(3)]; v1.dedup(); - let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3]; + let mut v2: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(3), Box::new(3)]; v2.dedup(); // If the boxed pointers were leaked or otherwise misused, valgrind // and/or rt should raise errors. |
