rust/tests/ui/fn/fn-trait-formatting.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
730 B
Rust
Raw Normal View History

2014-12-05 20:12:25 -06:00
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
fn main() {
let _: () = Box::new(|_: isize| {}) as Box<dyn FnOnce(isize)>;
//~^ ERROR mismatched types
2019-11-14 16:08:08 -06:00
//~| expected unit type `()`
//~| found struct `Box<dyn FnOnce(isize)>`
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 `()`
//~| found struct `Box<dyn Fn(isize, isize)>`
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 `()`
//~| found struct `Box<dyn FnMut() -> isize>`
2015-01-31 10:23:42 -06:00
needs_fn(1);
//~^ ERROR expected a `Fn<(isize,)>` closure, found `{integer}`
}