]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Copyright 2012 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 | ||
b7449926 XL |
11 | // run-pass |
12 | #![allow(non_camel_case_types)] | |
13 | ||
c34b1796 | 14 | #[derive(Copy, Clone)] |
223e47cc | 15 | struct cat { |
1a4d82fc JJ |
16 | meow: extern "Rust" fn(), |
17 | } | |
18 | ||
1a4d82fc JJ |
19 | fn meow() { |
20 | println!("meow") | |
223e47cc LB |
21 | } |
22 | ||
23 | fn cat() -> cat { | |
24 | cat { | |
1a4d82fc | 25 | meow: meow, |
223e47cc LB |
26 | } |
27 | } | |
28 | ||
c34b1796 | 29 | #[derive(Copy, Clone)] |
223e47cc LB |
30 | struct KittyInfo {kitty: cat} |
31 | ||
32 | // Code compiles and runs successfully if we add a + before the first arg | |
33 | fn nyan(kitty: cat, _kitty_info: KittyInfo) { | |
34 | (kitty.meow)(); | |
35 | } | |
36 | ||
37 | pub fn main() { | |
1a4d82fc JJ |
38 | let kitty = cat(); |
39 | nyan(kitty, KittyInfo {kitty: kitty}); | |
223e47cc | 40 | } |