From cdb8e64bc78400f9366db3b556bb01f470855f55 Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 29 May 2022 00:40:47 +0200 Subject: [PATCH] Use Box::new() instead of box syntax in core tests --- library/core/tests/any.rs | 9 ++++++--- library/core/tests/clone.rs | 4 ++-- library/core/tests/iter/traits/double_ended.rs | 3 ++- library/core/tests/lib.rs | 1 - library/core/tests/option.rs | 4 ++-- library/core/tests/result.rs | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs index eccddcbbf59..0dffd137565 100644 --- a/library/core/tests/any.rs +++ b/library/core/tests/any.rs @@ -24,8 +24,11 @@ fn any_referenced() { #[test] fn any_owning() { - let (a, b, c) = - (box 5_usize as Box, box TEST as Box, box Test as Box); + let (a, b, c) = ( + Box::new(5_usize) as Box, + Box::new(TEST) as Box, + Box::new(Test) as Box, + ); assert!(a.is::()); assert!(!b.is::()); @@ -58,7 +61,7 @@ fn any_downcast_ref() { #[test] fn any_downcast_mut() { let mut a = 5_usize; - let mut b: Box<_> = box 7_usize; + let mut b: Box<_> = Box::new(7_usize); let a_r = &mut a as &mut dyn Any; let tmp: &mut usize = &mut *b; diff --git a/library/core/tests/clone.rs b/library/core/tests/clone.rs index c97a87aebce..33ca9f2c6a3 100644 --- a/library/core/tests/clone.rs +++ b/library/core/tests/clone.rs @@ -8,8 +8,8 @@ fn test_borrowed_clone() { #[test] fn test_clone_from() { - let a = box 5; - let mut b = box 10; + let a = Box::new(5); + let mut b = Box::new(10); b.clone_from(&a); assert_eq!(*b, 5); } diff --git a/library/core/tests/iter/traits/double_ended.rs b/library/core/tests/iter/traits/double_ended.rs index 947d19d3dfe..00ef4a6e6a9 100644 --- a/library/core/tests/iter/traits/double_ended.rs +++ b/library/core/tests/iter/traits/double_ended.rs @@ -78,7 +78,8 @@ fn test_rev_rposition() { #[test] #[should_panic] fn test_rposition_panic() { - let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), (box 0, box 0), (box 0, box 0)]; + let u = (Box::new(0), Box::new(0)); + let v: [(Box<_>, Box<_>); 4] = [u.clone(), u.clone(), u.clone(), u]; let mut i = 0; v.iter().rposition(|_elt| { if i == 2 { diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 9ea374e1045..7e9d7d27101 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -3,7 +3,6 @@ #![feature(array_methods)] #![feature(array_windows)] #![feature(bench_black_box)] -#![feature(box_syntax)] #![feature(cell_update)] #![feature(const_assume)] #![feature(const_black_box)] diff --git a/library/core/tests/option.rs b/library/core/tests/option.rs index da692461261..9f5e537dcef 100644 --- a/library/core/tests/option.rs +++ b/library/core/tests/option.rs @@ -7,7 +7,7 @@ use core::option::*; #[test] fn test_get_ptr() { unsafe { - let x: Box<_> = box 0; + let x: Box<_> = Box::new(0); let addr_x: *const isize = mem::transmute(&*x); let opt = Some(x); let y = opt.unwrap(); @@ -315,7 +315,7 @@ fn test_collect() { // test that it does not take more elements than it needs let mut functions: [Box Option<()>>; 3] = - [box || Some(()), box || None, box || panic!()]; + [Box::new(|| Some(())), Box::new(|| None), Box::new(|| panic!())]; let v: Option> = functions.iter_mut().map(|f| (*f)()).collect(); diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 98b870512b0..103e8cc3a96 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -69,7 +69,7 @@ fn test_collect() { // test that it does not take more elements than it needs let mut functions: [Box Result<(), isize>>; 3] = - [box || Ok(()), box || Err(1), box || panic!()]; + [Box::new(|| Ok(())), Box::new(|| Err(1)), Box::new(|| panic!())]; let v: Result, isize> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == Err(1));