Skip to content

Commit

Permalink
Add closure defined outside of call case to arg count mismatch test
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Dec 11, 2017
1 parent 8ee82d0 commit 92da913
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/test/ui/mismatched_types/closure-arg-count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
12 changes: 10 additions & 2 deletions src/test/ui/mismatched_types/closure-arg-count.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions src/test/ui/mismatched_types/fn-variance-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
10 changes: 5 additions & 5 deletions src/test/ui/mismatched_types/fn-variance-1.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand Down

0 comments on commit 92da913

Please sign in to comment.