Use Box::new() instead of box syntax in core tests
This commit is contained in:
parent
d75c60f9a3
commit
cdb8e64bc7
6 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue