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