Skip to content

Commit cdb8e64

Browse files
committed
Use Box::new() instead of box syntax in core tests
1 parent d75c60f commit cdb8e64

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

library/core/tests/any.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ fn any_referenced() {
2424

2525
#[test]
2626
fn any_owning() {
27-
let (a, b, c) =
28-
(box 5_usize as Box<dyn Any>, box TEST as Box<dyn Any>, box Test as Box<dyn Any>);
27+
let (a, b, c) = (
28+
Box::new(5_usize) as Box<dyn Any>,
29+
Box::new(TEST) as Box<dyn Any>,
30+
Box::new(Test) as Box<dyn Any>,
31+
);
2932

3033
assert!(a.is::<usize>());
3134
assert!(!b.is::<usize>());
@@ -58,7 +61,7 @@ fn any_downcast_ref() {
5861
#[test]
5962
fn any_downcast_mut() {
6063
let mut a = 5_usize;
61-
let mut b: Box<_> = box 7_usize;
64+
let mut b: Box<_> = Box::new(7_usize);
6265

6366
let a_r = &mut a as &mut dyn Any;
6467
let tmp: &mut usize = &mut *b;

library/core/tests/clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ fn test_borrowed_clone() {
88

99
#[test]
1010
fn test_clone_from() {
11-
let a = box 5;
12-
let mut b = box 10;
11+
let a = Box::new(5);
12+
let mut b = Box::new(10);
1313
b.clone_from(&a);
1414
assert_eq!(*b, 5);
1515
}

library/core/tests/iter/traits/double_ended.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ fn test_rev_rposition() {
7878
#[test]
7979
#[should_panic]
8080
fn test_rposition_panic() {
81-
let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), (box 0, box 0), (box 0, box 0)];
81+
let u = (Box::new(0), Box::new(0));
82+
let v: [(Box<_>, Box<_>); 4] = [u.clone(), u.clone(), u.clone(), u];
8283
let mut i = 0;
8384
v.iter().rposition(|_elt| {
8485
if i == 2 {

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(array_methods)]
44
#![feature(array_windows)]
55
#![feature(bench_black_box)]
6-
#![feature(box_syntax)]
76
#![feature(cell_update)]
87
#![feature(const_assume)]
98
#![feature(const_black_box)]

library/core/tests/option.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::option::*;
77
#[test]
88
fn test_get_ptr() {
99
unsafe {
10-
let x: Box<_> = box 0;
10+
let x: Box<_> = Box::new(0);
1111
let addr_x: *const isize = mem::transmute(&*x);
1212
let opt = Some(x);
1313
let y = opt.unwrap();
@@ -315,7 +315,7 @@ fn test_collect() {
315315

316316
// test that it does not take more elements than it needs
317317
let mut functions: [Box<dyn Fn() -> Option<()>>; 3] =
318-
[box || Some(()), box || None, box || panic!()];
318+
[Box::new(|| Some(())), Box::new(|| None), Box::new(|| panic!())];
319319

320320
let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();
321321

library/core/tests/result.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn test_collect() {
6969

7070
// test that it does not take more elements than it needs
7171
let mut functions: [Box<dyn Fn() -> Result<(), isize>>; 3] =
72-
[box || Ok(()), box || Err(1), box || panic!()];
72+
[Box::new(|| Ok(())), Box::new(|| Err(1)), Box::new(|| panic!())];
7373

7474
let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();
7575
assert!(v == Err(1));

0 commit comments

Comments
 (0)