diff options
| author | est31 <MTest31@outlook.com> | 2022-05-29 00:40:47 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2022-05-29 01:44:11 +0200 |
| commit | cdb8e64bc78400f9366db3b556bb01f470855f55 (patch) | |
| tree | 1016d7c5605a52610b46e6a507f7faf91e927627 | |
| parent | d75c60f9a37c9b1810ddcdf19216da76319bdf04 (diff) | |
| download | rust-cdb8e64bc78400f9366db3b556bb01f470855f55.tar.gz rust-cdb8e64bc78400f9366db3b556bb01f470855f55.zip | |
Use Box::new() instead of box syntax in core tests
| -rw-r--r-- | library/core/tests/any.rs | 9 | ||||
| -rw-r--r-- | library/core/tests/clone.rs | 4 | ||||
| -rw-r--r-- | library/core/tests/iter/traits/double_ended.rs | 3 | ||||
| -rw-r--r-- | library/core/tests/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/tests/option.rs | 4 | ||||
| -rw-r--r-- | 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<dyn Any>, box TEST as Box<dyn Any>, box Test as Box<dyn Any>); + let (a, b, c) = ( + Box::new(5_usize) as Box<dyn Any>, + Box::new(TEST) as Box<dyn Any>, + Box::new(Test) as Box<dyn Any>, + ); assert!(a.is::<usize>()); assert!(!b.is::<usize>()); @@ -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<dyn Fn() -> Option<()>>; 3] = - [box || Some(()), box || None, box || panic!()]; + [Box::new(|| Some(())), Box::new(|| None), Box::new(|| panic!())]; let v: Option<Vec<()>> = 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<dyn Fn() -> Result<(), isize>>; 3] = - [box || Ok(()), box || Err(1), box || panic!()]; + [Box::new(|| Ok(())), Box::new(|| Err(1)), Box::new(|| panic!())]; let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == Err(1)); |
