Skip to content

Commit 9e52d22

Browse files
Correct meaning of two UI tests
1 parent 374d4d8 commit 9e52d22

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

src/test/ui/mismatched_types/E0631.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

src/test/ui/mismatched_types/E0631.stderr

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

15-
error[E0308]: mismatched types
15+
error[E0631]: type mismatch in closure arguments
1616
--> $DIR/E0631.rs:8:5
1717
|
1818
LL | bar(|_: isize| {});
19-
| ^^^ types differ
19+
| ^^^ ---------- found signature of `fn(isize) -> _`
20+
| |
21+
| expected signature of `fn(usize) -> _`
2022
|
21-
= note: expected trait `Fn<usize>`
22-
found trait `Fn<(isize,)>`
2323
note: required by a bound in `bar`
2424
--> $DIR/E0631.rs:4:11
2525
|
26-
LL | fn bar<F: Fn<usize>>(_: F) {}
27-
| ^^^^^^^^^ required by this bound in `bar`
26+
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
27+
| ^^^^^^^^^^^^ required by this bound in `bar`
2828

2929
error[E0631]: type mismatch in function arguments
3030
--> $DIR/E0631.rs:9:9
@@ -43,23 +43,23 @@ note: required by a bound in `foo`
4343
LL | fn foo<F: Fn(usize)>(_: F) {}
4444
| ^^^^^^^^^ required by this bound in `foo`
4545

46-
error[E0308]: mismatched types
46+
error[E0631]: type mismatch in function arguments
4747
--> $DIR/E0631.rs:10:9
4848
|
49+
LL | fn f(_: u64) {}
50+
| ------------ found signature of `fn(u64) -> _`
51+
...
4952
LL | bar(f);
50-
| --- ^ types differ
53+
| --- ^ expected signature of `fn(usize) -> _`
5154
| |
5255
| required by a bound introduced by this call
5356
|
54-
= note: expected trait `Fn<usize>`
55-
found trait `Fn<(u64,)>`
5657
note: required by a bound in `bar`
5758
--> $DIR/E0631.rs:4:11
5859
|
59-
LL | fn bar<F: Fn<usize>>(_: F) {}
60-
| ^^^^^^^^^ required by this bound in `bar`
60+
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
61+
| ^^^^^^^^^^^^ required by this bound in `bar`
6162

6263
error: aborting due to 4 previous errors
6364

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

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

+1-1
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

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)