rust/src/test/ui/fn/fn-trait-formatting.rs

22 lines
817 B
Rust
Raw Normal View History

2015-01-08 02:53:58 +00:00
#![feature(box_syntax)]
2014-12-06 02:12:25 +00:00
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
fn main() {
2019-05-28 18:46:13 +00:00
let _: () = (box |_: isize| {}) as Box<dyn FnOnce(isize)>;
//~^ ERROR mismatched types
2019-11-14 22:08:08 +00:00
//~| expected unit type `()`
//~| found struct `std::boxed::Box<dyn std::ops::FnOnce(isize)>`
2019-05-28 18:46:13 +00:00
let _: () = (box |_: 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 `()`
//~| found struct `std::boxed::Box<dyn std::ops::Fn(isize, isize)>`
2019-05-28 18:46:13 +00:00
let _: () = (box || -> 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 `()`
//~| found struct `std::boxed::Box<dyn std::ops::FnMut() -> isize>`
2015-01-31 16:23:42 +00:00
needs_fn(1);
//~^ ERROR expected a `std::ops::Fn<(isize,)>` closure, found `{integer}`
}