]> git.lizzy.rs Git - rust.git/blob - tests/ui/mismatched_types/closure-arg-count.rs
Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcm
[rust.git] / tests / ui / mismatched_types / closure-arg-count.rs
1 #![feature(unboxed_closures)]
2
3 fn f<F: Fn<(usize,)>>(_: F) {}
4 fn main() {
5     [1, 2, 3].sort_by(|| panic!());
6     //~^ ERROR closure is expected to take
7     [1, 2, 3].sort_by(|tuple| panic!());
8     //~^ ERROR closure is expected to take
9     [1, 2, 3].sort_by(|(tuple, tuple2)| panic!());
10     //~^ ERROR closure is expected to take
11     [1, 2, 3].sort_by(|(tuple, tuple2): (usize, _)| panic!());
12     //~^ ERROR closure is expected to take
13     f(|| panic!());
14     //~^ ERROR closure is expected to take
15     f(  move    || panic!());
16     //~^ ERROR closure is expected to take
17
18     let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
19     //~^ ERROR closure is expected to take
20     let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i);
21     //~^ ERROR closure is expected to take
22     let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i);
23     //~^ ERROR closure is expected to take
24     let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
25     //~^ ERROR function is expected to take
26     let bar = |i, x, y| i;
27     let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
28     //~^ ERROR closure is expected to take
29     let _it = vec![1, 2, 3].into_iter().enumerate().map(qux);
30     //~^ ERROR function is expected to take
31
32     let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
33     //~^ ERROR function is expected to take
34
35     call(Foo);
36     //~^ ERROR function is expected to take
37 }
38
39 fn foo() {}
40 fn qux(x: usize, y: usize) {}
41
42 fn call<F, R>(_: F) where F: FnOnce() -> R {}
43 struct Foo(u8);