aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/closure4.rs
blob: 3f845dcd5648611b9240544231e437c15d831e3a (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
26
#![feature(lang_items)]
#[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
}