Add closure defined outside of call case to arg count mismatch test
This commit is contained in:
parent
8ee82d08ac
commit
92da91313c
|
@ -29,6 +29,9 @@ fn main() {
|
|||
//~^ ERROR closure is expected to take
|
||||
let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
|
||||
//~^ ERROR function is expected to take
|
||||
let bar = |i, x, y| i;
|
||||
let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
|
||||
//~^ ERROR closure is expected to take
|
||||
}
|
||||
|
||||
fn foo() {}
|
||||
|
|
|
@ -62,8 +62,16 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it
|
|||
30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
|
||||
| ^^^ expected function that takes a single 2-tuple as argument
|
||||
...
|
||||
34 | fn foo() {}
|
||||
37 | fn foo() {}
|
||||
| -------- takes 0 arguments
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
|
||||
--> $DIR/closure-arg-count.rs:33:53
|
||||
|
|
||||
32 | let bar = |i, x, y| i;
|
||||
| --------- takes 3 distinct arguments
|
||||
33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
|
||||
| ^^^ expected closure that takes a single 2-tuple as argument
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn takes_imm(x: &isize) { }
|
||||
//~^ NOTE found signature
|
||||
|
||||
fn takes_mut(x: &mut isize) { }
|
||||
//~^ NOTE found signature
|
||||
|
||||
fn apply<T, F>(t: T, f: F) where F: FnOnce(T) {
|
||||
f(t)
|
||||
|
@ -22,12 +24,10 @@ fn main() {
|
|||
//~^ ERROR type mismatch
|
||||
//~| NOTE required by `apply`
|
||||
//~| NOTE expected signature
|
||||
//~| NOTE found signature
|
||||
|
||||
apply(&mut 3, takes_mut);
|
||||
apply(&mut 3, takes_imm);
|
||||
//~^ ERROR type mismatch
|
||||
//~| NOTE required by `apply`
|
||||
//~| NOTE expected signature
|
||||
//~| NOTE found signature
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
error[E0631]: type mismatch in function arguments
|
||||
--> $DIR/fn-variance-1.rs:21:5
|
||||
--> $DIR/fn-variance-1.rs:23:5
|
||||
|
|
||||
13 | fn takes_mut(x: &mut isize) { }
|
||||
14 | fn takes_mut(x: &mut isize) { }
|
||||
| --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _`
|
||||
...
|
||||
21 | apply(&3, takes_mut);
|
||||
23 | apply(&3, takes_mut);
|
||||
| ^^^^^ expected signature of `fn(&{integer}) -> _`
|
||||
|
|
||||
= note: required by `apply`
|
||||
|
||||
error[E0631]: type mismatch in function arguments
|
||||
--> $DIR/fn-variance-1.rs:28:5
|
||||
--> $DIR/fn-variance-1.rs:29:5
|
||||
|
|
||||
11 | fn takes_imm(x: &isize) { }
|
||||
| ----------------------- found signature of `for<'r> fn(&'r isize) -> _`
|
||||
...
|
||||
28 | apply(&mut 3, takes_imm);
|
||||
29 | apply(&mut 3, takes_imm);
|
||||
| ^^^^^ expected signature of `fn(&mut {integer}) -> _`
|
||||
|
|
||||
= note: required by `apply`
|
||||
|
|
Loading…
Reference in New Issue