2021-06-12 05:48:04 -05:00
|
|
|
// Make sure that an error is reported if the `call` function of the
|
|
|
|
// `fn`/`fn_mut` lang item is grossly ill-formed.
|
|
|
|
|
|
|
|
#![feature(lang_items)]
|
|
|
|
#![feature(no_core)]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
#[lang = "fn"]
|
|
|
|
trait MyFn<T> {
|
|
|
|
const call: i32 = 42;
|
2021-09-24 11:55:14 -05:00
|
|
|
//~^ ERROR: `call` trait item in `fn` lang item must be a function
|
2021-06-12 05:48:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "fn_mut"]
|
|
|
|
trait MyFnMut<T> {
|
|
|
|
fn call(i: i32, j: i32) -> i32 { i + j }
|
2021-09-24 11:55:14 -05:00
|
|
|
//~^ ERROR: first argument of `call` in `fn_mut` lang item must be a reference
|
2021-06-12 05:48:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a = || 42;
|
|
|
|
a();
|
|
|
|
|
|
|
|
let mut i = 0;
|
|
|
|
let mut b = || { i += 1; };
|
|
|
|
b();
|
|
|
|
}
|