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.
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.
11 // See Issues #20055 and #21695.
13 // We are checking here that the temporaries `Box<[i8, k]>`, for `k`
14 // in 1, 2, 3, 4, that are induced by the match expression are
15 // properly handled, in that only *one* will be initialized by
16 // whichever arm is run, and subsequently dropped at the end of the
17 // statement surrounding the `match`.
23 impl Boo for [i8; 1] { }
24 impl Boo for [i8; 2] { }
25 impl Boo for [i8; 3] { }
26 impl Boo for [i8; 4] { }
28 pub fn foo(box_1: fn () -> Box<[i8; 1]>,
29 box_2: fn () -> Box<[i8; 2]>,
30 box_3: fn () -> Box<[i8; 3]>,
31 box_4: fn () -> Box<[i8; 4]>,
33 println!("Hello World 1");
34 let _: Box<Boo> = match 3 {
40 println!("Hello World 2");
44 fn box_1() -> Box<[i8; 1]> { Box::new( [1i8; 1] ) }
45 fn box_2() -> Box<[i8; 2]> { Box::new( [1i8; 2] ) }
46 fn box_3() -> Box<[i8; 3]> { Box::new( [1i8; 3] ) }
47 fn box_4() -> Box<[i8; 4]> { Box::new( [1i8; 4] ) }
49 foo(box_1, box_2, box_3, box_4);