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