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