aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/closure4.rs
blob: 07017760789696558e50051ba0f7ec67ec7dc3e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#[lang = "sized"]
pub trait Sized {}

#[lang = "fn_once"]
pub trait FnOnce<Args> {
    #[lang = "fn_once_output"]
    type Output;

    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}

struct Foo(i32, i32);

fn main() -> i32 {
  let foo = |&x: &i32, y: i32| -> i32 {
    x + y
  };
  
  let bar = |Foo(x, y): Foo| -> i32 {
    x + y
  };

  let a = 4;
  foo(&a, 2) + bar(Foo(100, 200)) - 306
}