Skip to content

Commit 1c084f1

Browse files
Correct meaning of two UI tests
1 parent 8b64988 commit 1c084f1

File tree

4 files changed

+45
-34
lines changed

4 files changed

+45
-34
lines changed

src/test/ui/mismatched_types/E0631.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![feature(unboxed_closures)]
22

33
fn foo<F: Fn(usize)>(_: F) {}
4-
fn bar<F: Fn<usize>>(_: F) {}
4+
fn bar<F: Fn<(usize,)>>(_: F) {}
55
fn main() {
66
fn f(_: u64) {}
77
foo(|_: isize| {}); //~ ERROR type mismatch
8-
bar(|_: isize| {}); //~ ERROR mismatched types
8+
bar(|_: isize| {}); //~ ERROR type mismatch
99
foo(f); //~ ERROR type mismatch
10-
bar(f); //~ ERROR mismatched types
10+
bar(f); //~ ERROR type mismatch
1111
}

src/test/ui/mismatched_types/E0631.stderr

+18-14
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ note: required by a bound in `foo`
1414
LL | fn foo<F: Fn(usize)>(_: F) {}
1515
| ^^^^^^^^^ required by this bound in `foo`
1616

17-
error[E0308]: mismatched types
17+
error[E0631]: type mismatch in closure arguments
1818
--> $DIR/E0631.rs:8:5
1919
|
2020
LL | bar(|_: isize| {});
21-
| ^^^ types differ
21+
| ^^^ ---------- found signature defined here
22+
| |
23+
| expected due to this
2224
|
23-
= note: expected trait `Fn<usize>`
24-
found trait `Fn<(isize,)>`
25+
= note: expected closure signature `fn(usize) -> _`
26+
found closure signature `fn(isize) -> _`
2527
note: required by a bound in `bar`
2628
--> $DIR/E0631.rs:4:11
2729
|
28-
LL | fn bar<F: Fn<usize>>(_: F) {}
29-
| ^^^^^^^^^ required by this bound in `bar`
30+
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
31+
| ^^^^^^^^^^^^ required by this bound in `bar`
3032

3133
error[E0631]: type mismatch in function arguments
3234
--> $DIR/E0631.rs:9:9
@@ -47,23 +49,25 @@ note: required by a bound in `foo`
4749
LL | fn foo<F: Fn(usize)>(_: F) {}
4850
| ^^^^^^^^^ required by this bound in `foo`
4951

50-
error[E0308]: mismatched types
52+
error[E0631]: type mismatch in function arguments
5153
--> $DIR/E0631.rs:10:9
5254
|
55+
LL | fn f(_: u64) {}
56+
| ------------ found signature defined here
57+
...
5358
LL | bar(f);
54-
| --- ^ types differ
59+
| --- ^ expected due to this
5560
| |
5661
| required by a bound introduced by this call
5762
|
58-
= note: expected trait `Fn<usize>`
59-
found trait `Fn<(u64,)>`
63+
= note: expected function signature `fn(usize) -> _`
64+
found function signature `fn(u64) -> _`
6065
note: required by a bound in `bar`
6166
--> $DIR/E0631.rs:4:11
6267
|
63-
LL | fn bar<F: Fn<usize>>(_: F) {}
64-
| ^^^^^^^^^ required by this bound in `bar`
68+
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
69+
| ^^^^^^^^^^^^ required by this bound in `bar`
6570

6671
error: aborting due to 4 previous errors
6772

68-
Some errors have detailed explanations: E0308, E0631.
69-
For more information about an error, try `rustc --explain E0308`.
73+
For more information about this error, try `rustc --explain E0631`.

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(unboxed_closures)]
22

3-
fn f<F: Fn<usize>>(_: F) {}
3+
fn f<F: Fn<(usize,)>>(_: F) {}
44
fn main() {
55
[1, 2, 3].sort_by(|| panic!());
66
//~^ ERROR closure is expected to take
@@ -11,9 +11,9 @@ fn main() {
1111
[1, 2, 3].sort_by(|(tuple, tuple2): (usize, _)| panic!());
1212
//~^ ERROR closure is expected to take
1313
f(|| panic!());
14-
//~^ ERROR mismatched types
14+
//~^ ERROR closure is expected to take
1515
f( move || panic!());
16-
//~^ ERROR mismatched types
16+
//~^ ERROR closure is expected to take
1717

1818
let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
1919
//~^ ERROR closure is expected to take

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

+21-14
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,41 @@ help: change the closure to take multiple arguments instead of a single tuple
4545
LL | [1, 2, 3].sort_by(|tuple, tuple2| panic!());
4646
| ~~~~~~~~~~~~~~~
4747

48-
error[E0308]: mismatched types
48+
error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
4949
--> $DIR/closure-arg-count.rs:13:5
5050
|
5151
LL | f(|| panic!());
52-
| ^ types differ
52+
| ^ -- takes 0 arguments
53+
| |
54+
| expected closure that takes 1 argument
5355
|
54-
= note: expected trait `Fn<usize>`
55-
found trait `Fn<()>`
5656
note: required by a bound in `f`
5757
--> $DIR/closure-arg-count.rs:3:9
5858
|
59-
LL | fn f<F: Fn<usize>>(_: F) {}
60-
| ^^^^^^^^^ required by this bound in `f`
59+
LL | fn f<F: Fn<(usize,)>>(_: F) {}
60+
| ^^^^^^^^^^^^ required by this bound in `f`
61+
help: consider changing the closure to take and ignore the expected argument
62+
|
63+
LL | f(|_| panic!());
64+
| ~~~
6165

62-
error[E0308]: mismatched types
66+
error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
6367
--> $DIR/closure-arg-count.rs:15:5
6468
|
6569
LL | f( move || panic!());
66-
| ^ types differ
70+
| ^ ---------- takes 0 arguments
71+
| |
72+
| expected closure that takes 1 argument
6773
|
68-
= note: expected trait `Fn<usize>`
69-
found trait `Fn<()>`
7074
note: required by a bound in `f`
7175
--> $DIR/closure-arg-count.rs:3:9
7276
|
73-
LL | fn f<F: Fn<usize>>(_: F) {}
74-
| ^^^^^^^^^ required by this bound in `f`
77+
LL | fn f<F: Fn<(usize,)>>(_: F) {}
78+
| ^^^^^^^^^^^^ required by this bound in `f`
79+
help: consider changing the closure to take and ignore the expected argument
80+
|
81+
LL | f( move |_| panic!());
82+
| ~~~
7583

7684
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
7785
--> $DIR/closure-arg-count.rs:18:53
@@ -190,5 +198,4 @@ LL | fn call<F, R>(_: F) where F: FnOnce() -> R {}
190198

191199
error: aborting due to 14 previous errors
192200

193-
Some errors have detailed explanations: E0308, E0593.
194-
For more information about an error, try `rustc --explain E0308`.
201+
For more information about this error, try `rustc --explain E0593`.

0 commit comments

Comments
 (0)