]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-15571.rs
Rollup merge of #91804 - woppopo:const_clone, r=oli-obk
[rust.git] / src / test / ui / issues / issue-15571.rs
1 // run-pass
2 #![feature(box_syntax)]
3
4 fn match_on_local() {
5     let mut foo: Option<Box<_>> = Some(box 5);
6     match foo {
7         None => {},
8         Some(x) => {
9             foo = Some(x);
10         }
11     }
12     println!("'{}'", foo.unwrap());
13 }
14
15 fn match_on_arg(mut foo: Option<Box<i32>>) {
16     match foo {
17         None => {}
18         Some(x) => {
19             foo = Some(x);
20         }
21     }
22     println!("'{}'", foo.unwrap());
23 }
24
25 fn match_on_binding() {
26     match Some(Box::new(7)) {
27         mut foo => {
28             match foo {
29                 None => {},
30                 Some(x) => {
31                     foo = Some(x);
32                 }
33             }
34             println!("'{}'", foo.unwrap());
35         }
36     }
37 }
38
39 fn match_on_upvar() {
40     let mut foo: Option<Box<_>> = Some(box 8);
41     let f = move|| {
42         match foo {
43             None => {},
44             Some(x) => {
45                 foo = Some(x);
46             }
47         }
48         println!("'{}'", foo.unwrap());
49     };
50     f();
51 }
52
53 fn main() {
54     match_on_local();
55     match_on_arg(Some(box 6));
56     match_on_binding();
57     match_on_upvar();
58 }