Skip to content

Commit 5b66c6d

Browse files
committed
Test cases for issue #20055.
Note that I have not yet managed to expose any bug in `trans::expr::into_fat_ptr`; it would be good to try to do so (or show that the use of `.to_lvalue_datum` there is sound).
1 parent 3264431 commit 5b66c6d

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Boo { }
12+
13+
impl Boo for [i8; 1] { }
14+
impl Boo for [i8; 2] { }
15+
impl Boo for [i8; 3] { }
16+
impl Boo for [i8; 4] { }
17+
18+
pub fn foo(box_1: fn () -> Box<[i8; 1]>,
19+
box_2: fn () -> Box<[i8; 20]>,
20+
box_3: fn () -> Box<[i8; 300]>,
21+
box_4: fn () -> Box<[i8; 4000]>,
22+
) {
23+
println!("Hello World 1");
24+
let _: Box<[i8]> = match 3 {
25+
1 => box_1(),
26+
2 => box_2(),
27+
3 => box_3(),
28+
_ => box_4(),
29+
};
30+
println!("Hello World 2");
31+
}
32+
33+
pub fn main() {
34+
fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) }
35+
fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) }
36+
fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) }
37+
fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) }
38+
39+
foo(box_1, box_2, box_3, box_4);
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn foo(box_1: fn () -> Box<[i8; 1]>,
12+
box_2: fn () -> Box<[i8; 20]>,
13+
box_3: fn () -> Box<[i8; 300]>,
14+
box_4: fn () -> Box<[i8; 4000]>,
15+
) {
16+
println!("Hello World 1");
17+
let _: Box<[i8]> = match 3 {
18+
1 => box_1(),
19+
2 => box_2(),
20+
3 => box_3(),
21+
_ => box_4(),
22+
};
23+
println!("Hello World 2");
24+
}
25+
26+
pub fn main() {
27+
fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) }
28+
fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) }
29+
fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) }
30+
fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) }
31+
32+
foo(box_1, box_2, box_3, box_4);
33+
}

0 commit comments

Comments
 (0)