diff options
| author | est31 <MTest31@outlook.com> | 2022-05-29 00:25:32 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2022-05-29 01:44:11 +0200 |
| commit | d75c60f9a37c9b1810ddcdf19216da76319bdf04 (patch) | |
| tree | db61a2b833b4d163e0a90fcdda6d6dff983ed9cd | |
| parent | 7230a15c32d01e1653d98c39ddd79097a59b550c (diff) | |
| download | rust-d75c60f9a37c9b1810ddcdf19216da76319bdf04.tar.gz rust-d75c60f9a37c9b1810ddcdf19216da76319bdf04.zip | |
Use Box::new() instead of box syntax in std tests
| -rw-r--r-- | library/std/src/io/error/tests.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sync/mpsc/mpsc_queue/tests.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sync/mpsc/spsc_queue/tests.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sync/mpsc/sync_tests.rs | 12 | ||||
| -rw-r--r-- | library/std/src/sync/mpsc/tests.rs | 14 | ||||
| -rw-r--r-- | library/std/src/thread/tests.rs | 4 |
6 files changed, 22 insertions, 22 deletions
diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs index 6fd15fa8048..8d7877bcad3 100644 --- a/library/std/src/io/error/tests.rs +++ b/library/std/src/io/error/tests.rs @@ -17,10 +17,10 @@ fn test_debug_error() { let msg = error_string(code); let kind = decode_error_kind(code); let err = Error { - repr: Repr::new_custom(box Custom { + repr: Repr::new_custom(Box::new(Custom { kind: ErrorKind::InvalidInput, - error: box Error { repr: super::Repr::new_os(code) }, - }), + error: Box::new(Error { repr: super::Repr::new_os(code) }), + })), }; let expected = format!( "Custom {{ \ diff --git a/library/std/src/sync/mpsc/mpsc_queue/tests.rs b/library/std/src/sync/mpsc/mpsc_queue/tests.rs index 348b83424b0..9f4f31ed051 100644 --- a/library/std/src/sync/mpsc/mpsc_queue/tests.rs +++ b/library/std/src/sync/mpsc/mpsc_queue/tests.rs @@ -6,8 +6,8 @@ use crate::thread; #[test] fn test_full() { let q: Queue<Box<_>> = Queue::new(); - q.push(box 1); - q.push(box 2); + q.push(Box::new(1)); + q.push(Box::new(2)); } #[test] diff --git a/library/std/src/sync/mpsc/spsc_queue/tests.rs b/library/std/src/sync/mpsc/spsc_queue/tests.rs index e4fd15cbbde..467ef3dbdcb 100644 --- a/library/std/src/sync/mpsc/spsc_queue/tests.rs +++ b/library/std/src/sync/mpsc/spsc_queue/tests.rs @@ -47,8 +47,8 @@ fn peek() { fn drop_full() { unsafe { let q: Queue<Box<_>> = Queue::with_additions(0, (), ()); - q.push(box 1); - q.push(box 2); + q.push(Box::new(1)); + q.push(Box::new(2)); } } diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs index 0052a38f7bb..e58649bab6e 100644 --- a/library/std/src/sync/mpsc/sync_tests.rs +++ b/library/std/src/sync/mpsc/sync_tests.rs @@ -20,7 +20,7 @@ fn smoke() { #[test] fn drop_full() { let (tx, _rx) = sync_channel::<Box<isize>>(1); - tx.send(box 1).unwrap(); + tx.send(Box::new(1)).unwrap(); } #[test] @@ -238,7 +238,7 @@ fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = sync_channel::<Box<i32>>(0); drop(rx); - assert!(tx.send(box 0).is_err()); + assert!(tx.send(Box::new(0)).is_err()); } #[test] @@ -257,7 +257,7 @@ fn oneshot_single_thread_recv_chan_close() { #[test] fn oneshot_single_thread_send_then_recv() { let (tx, rx) = sync_channel::<Box<i32>>(1); - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); assert!(*rx.recv().unwrap() == 10); } @@ -333,7 +333,7 @@ fn oneshot_multi_task_recv_then_send() { assert!(*rx.recv().unwrap() == 10); }); - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); } #[test] @@ -398,7 +398,7 @@ fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::<Box<i32>>(0); let _t = thread::spawn(move || { - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); }); assert!(*rx.recv().unwrap() == 10); } @@ -418,7 +418,7 @@ fn stream_send_recv_stress() { } thread::spawn(move || { - tx.send(box i).unwrap(); + tx.send(Box::new(i)).unwrap(); send(tx, i + 1); }); } diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs index 184ce193cbe..4deb3e59615 100644 --- a/library/std/src/sync/mpsc/tests.rs +++ b/library/std/src/sync/mpsc/tests.rs @@ -20,7 +20,7 @@ fn smoke() { #[test] fn drop_full() { let (tx, _rx) = channel::<Box<isize>>(); - tx.send(box 1).unwrap(); + tx.send(Box::new(1)).unwrap(); } #[test] @@ -28,7 +28,7 @@ fn drop_full_shared() { let (tx, _rx) = channel::<Box<isize>>(); drop(tx.clone()); drop(tx.clone()); - tx.send(box 1).unwrap(); + tx.send(Box::new(1)).unwrap(); } #[test] @@ -229,7 +229,7 @@ fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = channel::<Box<i32>>(); drop(rx); - assert!(tx.send(box 0).is_err()); + assert!(tx.send(Box::new(0)).is_err()); } #[test] @@ -248,7 +248,7 @@ fn oneshot_single_thread_recv_chan_close() { #[test] fn oneshot_single_thread_send_then_recv() { let (tx, rx) = channel::<Box<i32>>(); - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); assert!(*rx.recv().unwrap() == 10); } @@ -309,7 +309,7 @@ fn oneshot_multi_task_recv_then_send() { assert!(*rx.recv().unwrap() == 10); }); - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); } #[test] @@ -374,7 +374,7 @@ fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::<Box<isize>>(); let _t = thread::spawn(move || { - tx.send(box 10).unwrap(); + tx.send(Box::new(10)).unwrap(); }); assert!(*rx.recv().unwrap() == 10); } @@ -394,7 +394,7 @@ fn stream_send_recv_stress() { } thread::spawn(move || { - tx.send(box i).unwrap(); + tx.send(Box::new(i)).unwrap(); send(tx, i + 1); }); } diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 7386fe1c442..5b8309cf5d2 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -127,7 +127,7 @@ where { let (tx, rx) = channel(); - let x: Box<_> = box 1; + let x: Box<_> = Box::new(1); let x_in_parent = (&*x) as *const i32 as usize; spawnfn(Box::new(move || { @@ -219,7 +219,7 @@ fn test_try_panic_any_message_owned_str() { #[test] fn test_try_panic_any_message_any() { match thread::spawn(move || { - panic_any(box 413u16 as Box<dyn Any + Send>); + panic_any(Box::new(413u16) as Box<dyn Any + Send>); }) .join() { |
