Skip to content

Commit ef6d5e3

Browse files
committed
Placate box protocol by switching to Box::new in various test code.
1 parent 1b8813d commit ef6d5e3

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

src/libcoretest/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn test_transmute() {
9595
trait Foo { fn dummy(&self) { } }
9696
impl Foo for isize {}
9797

98-
let a = box 100isize as Box<Foo>;
98+
let a = Box::new(100isize) as Box<Foo>;
9999
unsafe {
100100
let x: ::core::raw::TraitObject = transmute(a);
101101
assert!(*(x.data as *const isize) == 100);

src/libcoretest/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn test_collect() {
234234

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

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

src/libcoretest/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn test_collect() {
8080

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

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

src/librustc_driver/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Emitter for ExpectErrorEmitter {
9292

9393
fn errors(msgs: &[&str]) -> (Box<Emitter+Send>, usize) {
9494
let v = msgs.iter().map(|m| m.to_string()).collect();
95-
(box ExpectErrorEmitter { messages: v } as Box<Emitter+Send>, msgs.len())
95+
(Box::new(ExpectErrorEmitter { messages: v }) as Box<Emitter+Send>, msgs.len())
9696
}
9797

9898
fn test_env<F>(source_string: &str,

src/libstd/thread/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ mod tests {
967967
#[test]
968968
fn test_try_panic_message_any() {
969969
match thread::spawn(move|| {
970-
panic!(box 413u16 as Box<Any + Send>);
970+
panic!(Box::new(413u16) as Box<Any + Send>);
971971
}).join() {
972972
Err(e) => {
973973
type T = Box<Any + Send>;

src/test/debuginfo/trait-pointers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ impl Trait for Struct {}
3333
fn main() {
3434
let stack_struct = Struct { a:0, b: 1.0 };
3535
let reference: &Trait = &stack_struct as &Trait;
36-
let unique: Box<Trait> = box Struct { a:2, b: 3.0 } as Box<Trait>;
36+
let unique: Box<Trait> = Box::new(Struct { a:2, b: 3.0 }) as Box<Trait>;
3737
}

0 commit comments

Comments
 (0)