gcc/testsuite/rust/execute/torture/closure4.rs
raw| 1 | #[lang = "sized"] |
| 2 | pub trait Sized {} |
| 3 | |
| 4 | #[lang = "fn_once"] |
| 5 | pub trait FnOnce<Args> { |
| 6 | #[lang = "fn_once_output"] |
| 7 | type Output; |
| 8 | |
| 9 | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; |
| 10 | } |
| 11 | |
| 12 | struct Foo(i32, i32); |
| 13 | |
| 14 | fn main() -> i32 { |
| 15 | let foo = |&x: &i32, y: i32| -> i32 { |
| 16 | x + y |
| 17 | }; |
| 18 | |
| 19 | let bar = |Foo(x, y): Foo| -> i32 { |
| 20 | x + y |
| 21 | }; |
| 22 | |
| 23 | let a = 4; |
| 24 | foo(&a, 2) + bar(Foo(100, 200)) - 306 |
| 25 | } |