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

22 lines
802 B
Rust
Raw Normal View History

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