summaryrefslogtreecommitdiffstats
path: root/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs
blob: 757c6538d05b032ccfff14a74ff2387b47425a6e (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// revisions: fn_once_bad_item fn_once_bad_sig fn_mut_bad_item fn_mut_bad_sig fn_bad_item fn_bad_sig

#![feature(lang_items)]
#![feature(no_core)]
#![no_core]

#[lang = "sized"]
trait Sized {}

#[cfg(any(fn_bad_item, fn_bad_sig))]
#[lang = "fn"]
trait MyFn<T> {
    #[cfg(fn_bad_sig)]
    fn call(i: i32) -> i32 { 0 }

    #[cfg(fn_bad_item)]
    const call: i32 = 42;
}

#[cfg(any(fn_mut_bad_item, fn_mut_bad_sig))]
#[lang = "fn_mut"]
trait MyFnMut<T> {
    #[cfg(fn_mut_bad_sig)]
    fn call_mut(i: i32) -> i32 { 0 }

    #[cfg(fn_mut_bad_item)]
    const call_mut: i32 = 42;
}

#[cfg(any(fn_once_bad_item, fn_once_bad_sig))]
#[lang = "fn_once"]
trait MyFnOnce<T> {
    #[cfg(fn_once_bad_sig)]
    fn call_once(i: i32) -> i32 { 0 }

    #[cfg(fn_once_bad_item)]
    const call_once: i32 = 42;
}

fn main() {
    let a = || 42;
    a();
    //~^ ERROR failed to find an overloaded call trait for closure call

    let mut i = 0;
    let mut b = || { };
    b();
    //~^ ERROR failed to find an overloaded call trait for closure call
}