2014-12-06 02:12:25 +00:00
|
|
|
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
|
2014-12-16 00:38:34 +00:00
|
|
|
|
2021-08-25 00:39:40 +00:00
|
|
|
|
|
|
|
|
2014-12-16 00:38:34 +00:00
|
|
|
fn main() {
|
2021-08-25 00:39:40 +00:00
|
|
|
let _: () = Box::new(|_: isize| {}) as Box<dyn FnOnce(isize)>;
|
2015-02-23 20:27:55 +00:00
|
|
|
//~^ ERROR mismatched types
|
2019-11-14 22:08:08 +00:00
|
|
|
//~| expected unit type `()`
|
2020-09-02 07:40:56 +00:00
|
|
|
//~| found struct `Box<dyn FnOnce(isize)>`
|
2021-08-25 00:39:40 +00:00
|
|
|
let _: () = Box::new(|_: isize, isize| {}) as Box<dyn Fn(isize, isize)>;
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2019-11-14 22:08:08 +00:00
|
|
|
//~| expected unit type `()`
|
2020-09-02 07:40:56 +00:00
|
|
|
//~| found struct `Box<dyn Fn(isize, isize)>`
|
2021-08-25 00:39:40 +00:00
|
|
|
let _: () = Box::new(|| -> isize { unimplemented!() }) as Box<dyn FnMut() -> isize>;
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2019-11-14 22:08:08 +00:00
|
|
|
//~| expected unit type `()`
|
2020-09-02 07:40:56 +00:00
|
|
|
//~| found struct `Box<dyn FnMut() -> isize>`
|
2014-12-16 00:38:34 +00:00
|
|
|
|
2015-01-31 16:23:42 +00:00
|
|
|
needs_fn(1);
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ ERROR expected a `Fn<(isize,)>` closure, found `{integer}`
|
2014-12-16 00:38:34 +00:00
|
|
|
}
|