Skip to content

Commit 92da913

Browse files
committed
Add closure defined outside of call case to arg count mismatch test
1 parent 8ee82d0 commit 92da913

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

src/test/ui/mismatched_types/closure-arg-count.rs

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ fn main() {
2929
//~^ ERROR closure is expected to take
3030
let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
3131
//~^ ERROR function is expected to take
32+
let bar = |i, x, y| i;
33+
let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
34+
//~^ ERROR closure is expected to take
3235
}
3336

3437
fn foo() {}

src/test/ui/mismatched_types/closure-arg-count.stderr

+10-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it
6262
30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
6363
| ^^^ expected function that takes a single 2-tuple as argument
6464
...
65-
34 | fn foo() {}
65+
37 | fn foo() {}
6666
| -------- takes 0 arguments
6767

68-
error: aborting due to 8 previous errors
68+
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
69+
--> $DIR/closure-arg-count.rs:33:53
70+
|
71+
32 | let bar = |i, x, y| i;
72+
| --------- takes 3 distinct arguments
73+
33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
74+
| ^^^ expected closure that takes a single 2-tuple as argument
75+
76+
error: aborting due to 9 previous errors
6977

src/test/ui/mismatched_types/fn-variance-1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
// except according to those terms.
1010

1111
fn takes_imm(x: &isize) { }
12+
//~^ NOTE found signature
1213

1314
fn takes_mut(x: &mut isize) { }
15+
//~^ NOTE found signature
1416

1517
fn apply<T, F>(t: T, f: F) where F: FnOnce(T) {
1618
f(t)
@@ -22,12 +24,10 @@ fn main() {
2224
//~^ ERROR type mismatch
2325
//~| NOTE required by `apply`
2426
//~| NOTE expected signature
25-
//~| NOTE found signature
2627

2728
apply(&mut 3, takes_mut);
2829
apply(&mut 3, takes_imm);
2930
//~^ ERROR type mismatch
3031
//~| NOTE required by `apply`
3132
//~| NOTE expected signature
32-
//~| NOTE found signature
3333
}

src/test/ui/mismatched_types/fn-variance-1.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error[E0631]: type mismatch in function arguments
2-
--> $DIR/fn-variance-1.rs:21:5
2+
--> $DIR/fn-variance-1.rs:23:5
33
|
4-
13 | fn takes_mut(x: &mut isize) { }
4+
14 | fn takes_mut(x: &mut isize) { }
55
| --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _`
66
...
7-
21 | apply(&3, takes_mut);
7+
23 | apply(&3, takes_mut);
88
| ^^^^^ expected signature of `fn(&{integer}) -> _`
99
|
1010
= note: required by `apply`
1111

1212
error[E0631]: type mismatch in function arguments
13-
--> $DIR/fn-variance-1.rs:28:5
13+
--> $DIR/fn-variance-1.rs:29:5
1414
|
1515
11 | fn takes_imm(x: &isize) { }
1616
| ----------------------- found signature of `for<'r> fn(&'r isize) -> _`
1717
...
18-
28 | apply(&mut 3, takes_imm);
18+
29 | apply(&mut 3, takes_imm);
1919
| ^^^^^ expected signature of `fn(&mut {integer}) -> _`
2020
|
2121
= note: required by `apply`

0 commit comments

Comments
 (0)