diff --git a/src/test/run-pass/issue-20055-box-trait.rs b/src/test/run-pass/issue-20055-box-trait.rs new file mode 100644 index 000000000000..fca63f91ca86 --- /dev/null +++ b/src/test/run-pass/issue-20055-box-trait.rs @@ -0,0 +1,40 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Boo { } + +impl Boo for [i8; 1] { } +impl Boo for [i8; 2] { } +impl Boo for [i8; 3] { } +impl Boo for [i8; 4] { } + +pub fn foo(box_1: fn () -> Box<[i8; 1]>, + box_2: fn () -> Box<[i8; 20]>, + box_3: fn () -> Box<[i8; 300]>, + box_4: fn () -> Box<[i8; 4000]>, + ) { + println!("Hello World 1"); + let _: Box<[i8]> = match 3 { + 1 => box_1(), + 2 => box_2(), + 3 => box_3(), + _ => box_4(), + }; + println!("Hello World 2"); +} + +pub fn main() { + fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) } + fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) } + fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) } + fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) } + + foo(box_1, box_2, box_3, box_4); +} diff --git a/src/test/run-pass/issue-20055-box-unsized-array.rs b/src/test/run-pass/issue-20055-box-unsized-array.rs new file mode 100644 index 000000000000..2f3f737d1a77 --- /dev/null +++ b/src/test/run-pass/issue-20055-box-unsized-array.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo(box_1: fn () -> Box<[i8; 1]>, + box_2: fn () -> Box<[i8; 20]>, + box_3: fn () -> Box<[i8; 300]>, + box_4: fn () -> Box<[i8; 4000]>, + ) { + println!("Hello World 1"); + let _: Box<[i8]> = match 3 { + 1 => box_1(), + 2 => box_2(), + 3 => box_3(), + _ => box_4(), + }; + println!("Hello World 2"); +} + +pub fn main() { + fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) } + fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) } + fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) } + fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) } + + foo(box_1, box_2, box_3, box_4); +}