]>
git.proxmox.com Git - rustc.git/blob - tests/ui/issues/issue-20055-box-trait.rs
2 // See Issues #20055 and #21695.
4 // We are checking here that the temporaries `Box<[i8, k]>`, for `k`
5 // in 1, 2, 3, 4, that are induced by the match expression are
6 // properly handled, in that only *one* will be initialized by
7 // whichever arm is run, and subsequently dropped at the end of the
8 // statement surrounding the `match`.
14 impl Boo
for [i8; 1] { }
15 impl Boo
for [i8; 2] { }
16 impl Boo
for [i8; 3] { }
17 impl Boo
for [i8; 4] { }
19 pub fn foo(box_1
: fn () -> Box
<[i8; 1]>,
20 box_2
: fn () -> Box
<[i8; 2]>,
21 box_3
: fn () -> Box
<[i8; 3]>,
22 box_4
: fn () -> Box
<[i8; 4]>,
24 println
!("Hello World 1");
25 let _
: Box
<dyn Boo
> = match 3 {
31 println
!("Hello World 2");
35 fn box_1() -> Box
<[i8; 1]> { Box::new( [1; 1] ) }
36 fn box_2() -> Box
<[i8; 2]> { Box::new( [1; 2] ) }
37 fn box_3() -> Box
<[i8; 3]> { Box::new( [1; 3] ) }
38 fn box_4() -> Box
<[i8; 4]> { Box::new( [1; 4] ) }
40 foo(box_1
, box_2
, box_3
, box_4
);