Skip to content

Commit d75c60f

Browse files
committed
Use Box::new() instead of box syntax in std tests
1 parent 7230a15 commit d75c60f

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

library/std/src/io/error/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fn test_debug_error() {
1717
let msg = error_string(code);
1818
let kind = decode_error_kind(code);
1919
let err = Error {
20-
repr: Repr::new_custom(box Custom {
20+
repr: Repr::new_custom(Box::new(Custom {
2121
kind: ErrorKind::InvalidInput,
22-
error: box Error { repr: super::Repr::new_os(code) },
23-
}),
22+
error: Box::new(Error { repr: super::Repr::new_os(code) }),
23+
})),
2424
};
2525
let expected = format!(
2626
"Custom {{ \

library/std/src/sync/mpsc/mpsc_queue/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::thread;
66
#[test]
77
fn test_full() {
88
let q: Queue<Box<_>> = Queue::new();
9-
q.push(box 1);
10-
q.push(box 2);
9+
q.push(Box::new(1));
10+
q.push(Box::new(2));
1111
}
1212

1313
#[test]

library/std/src/sync/mpsc/spsc_queue/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ fn peek() {
4747
fn drop_full() {
4848
unsafe {
4949
let q: Queue<Box<_>> = Queue::with_additions(0, (), ());
50-
q.push(box 1);
51-
q.push(box 2);
50+
q.push(Box::new(1));
51+
q.push(Box::new(2));
5252
}
5353
}
5454

library/std/src/sync/mpsc/sync_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn smoke() {
2020
#[test]
2121
fn drop_full() {
2222
let (tx, _rx) = sync_channel::<Box<isize>>(1);
23-
tx.send(box 1).unwrap();
23+
tx.send(Box::new(1)).unwrap();
2424
}
2525

2626
#[test]
@@ -238,7 +238,7 @@ fn oneshot_single_thread_send_port_close() {
238238
// Testing that the sender cleans up the payload if receiver is closed
239239
let (tx, rx) = sync_channel::<Box<i32>>(0);
240240
drop(rx);
241-
assert!(tx.send(box 0).is_err());
241+
assert!(tx.send(Box::new(0)).is_err());
242242
}
243243

244244
#[test]
@@ -257,7 +257,7 @@ fn oneshot_single_thread_recv_chan_close() {
257257
#[test]
258258
fn oneshot_single_thread_send_then_recv() {
259259
let (tx, rx) = sync_channel::<Box<i32>>(1);
260-
tx.send(box 10).unwrap();
260+
tx.send(Box::new(10)).unwrap();
261261
assert!(*rx.recv().unwrap() == 10);
262262
}
263263

@@ -333,7 +333,7 @@ fn oneshot_multi_task_recv_then_send() {
333333
assert!(*rx.recv().unwrap() == 10);
334334
});
335335

336-
tx.send(box 10).unwrap();
336+
tx.send(Box::new(10)).unwrap();
337337
}
338338

339339
#[test]
@@ -398,7 +398,7 @@ fn oneshot_multi_thread_send_recv_stress() {
398398
for _ in 0..stress_factor() {
399399
let (tx, rx) = sync_channel::<Box<i32>>(0);
400400
let _t = thread::spawn(move || {
401-
tx.send(box 10).unwrap();
401+
tx.send(Box::new(10)).unwrap();
402402
});
403403
assert!(*rx.recv().unwrap() == 10);
404404
}
@@ -418,7 +418,7 @@ fn stream_send_recv_stress() {
418418
}
419419

420420
thread::spawn(move || {
421-
tx.send(box i).unwrap();
421+
tx.send(Box::new(i)).unwrap();
422422
send(tx, i + 1);
423423
});
424424
}

library/std/src/sync/mpsc/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ fn smoke() {
2020
#[test]
2121
fn drop_full() {
2222
let (tx, _rx) = channel::<Box<isize>>();
23-
tx.send(box 1).unwrap();
23+
tx.send(Box::new(1)).unwrap();
2424
}
2525

2626
#[test]
2727
fn drop_full_shared() {
2828
let (tx, _rx) = channel::<Box<isize>>();
2929
drop(tx.clone());
3030
drop(tx.clone());
31-
tx.send(box 1).unwrap();
31+
tx.send(Box::new(1)).unwrap();
3232
}
3333

3434
#[test]
@@ -229,7 +229,7 @@ fn oneshot_single_thread_send_port_close() {
229229
// Testing that the sender cleans up the payload if receiver is closed
230230
let (tx, rx) = channel::<Box<i32>>();
231231
drop(rx);
232-
assert!(tx.send(box 0).is_err());
232+
assert!(tx.send(Box::new(0)).is_err());
233233
}
234234

235235
#[test]
@@ -248,7 +248,7 @@ fn oneshot_single_thread_recv_chan_close() {
248248
#[test]
249249
fn oneshot_single_thread_send_then_recv() {
250250
let (tx, rx) = channel::<Box<i32>>();
251-
tx.send(box 10).unwrap();
251+
tx.send(Box::new(10)).unwrap();
252252
assert!(*rx.recv().unwrap() == 10);
253253
}
254254

@@ -309,7 +309,7 @@ fn oneshot_multi_task_recv_then_send() {
309309
assert!(*rx.recv().unwrap() == 10);
310310
});
311311

312-
tx.send(box 10).unwrap();
312+
tx.send(Box::new(10)).unwrap();
313313
}
314314

315315
#[test]
@@ -374,7 +374,7 @@ fn oneshot_multi_thread_send_recv_stress() {
374374
for _ in 0..stress_factor() {
375375
let (tx, rx) = channel::<Box<isize>>();
376376
let _t = thread::spawn(move || {
377-
tx.send(box 10).unwrap();
377+
tx.send(Box::new(10)).unwrap();
378378
});
379379
assert!(*rx.recv().unwrap() == 10);
380380
}
@@ -394,7 +394,7 @@ fn stream_send_recv_stress() {
394394
}
395395

396396
thread::spawn(move || {
397-
tx.send(box i).unwrap();
397+
tx.send(Box::new(i)).unwrap();
398398
send(tx, i + 1);
399399
});
400400
}

library/std/src/thread/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ where
127127
{
128128
let (tx, rx) = channel();
129129

130-
let x: Box<_> = box 1;
130+
let x: Box<_> = Box::new(1);
131131
let x_in_parent = (&*x) as *const i32 as usize;
132132

133133
spawnfn(Box::new(move || {
@@ -219,7 +219,7 @@ fn test_try_panic_any_message_owned_str() {
219219
#[test]
220220
fn test_try_panic_any_message_any() {
221221
match thread::spawn(move || {
222-
panic_any(box 413u16 as Box<dyn Any + Send>);
222+
panic_any(Box::new(413u16) as Box<dyn Any + Send>);
223223
})
224224
.join()
225225
{

0 commit comments

Comments
 (0)