Correct meaning of two UI tests
This commit is contained in:
parent
8b64988575
commit
1c084f15f3
@ -1,11 +1,11 @@
|
|||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
|
|
||||||
fn foo<F: Fn(usize)>(_: F) {}
|
fn foo<F: Fn(usize)>(_: F) {}
|
||||||
fn bar<F: Fn<usize>>(_: F) {}
|
fn bar<F: Fn<(usize,)>>(_: F) {}
|
||||||
fn main() {
|
fn main() {
|
||||||
fn f(_: u64) {}
|
fn f(_: u64) {}
|
||||||
foo(|_: isize| {}); //~ ERROR type mismatch
|
foo(|_: isize| {}); //~ ERROR type mismatch
|
||||||
bar(|_: isize| {}); //~ ERROR mismatched types
|
bar(|_: isize| {}); //~ ERROR type mismatch
|
||||||
foo(f); //~ ERROR type mismatch
|
foo(f); //~ ERROR type mismatch
|
||||||
bar(f); //~ ERROR mismatched types
|
bar(f); //~ ERROR type mismatch
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,21 @@ note: required by a bound in `foo`
|
|||||||
LL | fn foo<F: Fn(usize)>(_: F) {}
|
LL | fn foo<F: Fn(usize)>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^ required by this bound in `foo`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0631]: type mismatch in closure arguments
|
||||||
--> $DIR/E0631.rs:8:5
|
--> $DIR/E0631.rs:8:5
|
||||||
|
|
|
|
||||||
LL | bar(|_: isize| {});
|
LL | bar(|_: isize| {});
|
||||||
| ^^^ types differ
|
| ^^^ ---------- found signature defined here
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected trait `Fn<usize>`
|
= note: expected closure signature `fn(usize) -> _`
|
||||||
found trait `Fn<(isize,)>`
|
found closure signature `fn(isize) -> _`
|
||||||
note: required by a bound in `bar`
|
note: required by a bound in `bar`
|
||||||
--> $DIR/E0631.rs:4:11
|
--> $DIR/E0631.rs:4:11
|
||||||
|
|
|
|
||||||
LL | fn bar<F: Fn<usize>>(_: F) {}
|
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `bar`
|
| ^^^^^^^^^^^^ required by this bound in `bar`
|
||||||
|
|
||||||
error[E0631]: type mismatch in function arguments
|
error[E0631]: type mismatch in function arguments
|
||||||
--> $DIR/E0631.rs:9:9
|
--> $DIR/E0631.rs:9:9
|
||||||
@ -47,23 +49,25 @@ note: required by a bound in `foo`
|
|||||||
LL | fn foo<F: Fn(usize)>(_: F) {}
|
LL | fn foo<F: Fn(usize)>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `foo`
|
| ^^^^^^^^^ required by this bound in `foo`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0631]: type mismatch in function arguments
|
||||||
--> $DIR/E0631.rs:10:9
|
--> $DIR/E0631.rs:10:9
|
||||||
|
|
|
|
||||||
|
LL | fn f(_: u64) {}
|
||||||
|
| ------------ found signature defined here
|
||||||
|
...
|
||||||
LL | bar(f);
|
LL | bar(f);
|
||||||
| --- ^ types differ
|
| --- ^ expected due to this
|
||||||
| |
|
| |
|
||||||
| required by a bound introduced by this call
|
| required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= note: expected trait `Fn<usize>`
|
= note: expected function signature `fn(usize) -> _`
|
||||||
found trait `Fn<(u64,)>`
|
found function signature `fn(u64) -> _`
|
||||||
note: required by a bound in `bar`
|
note: required by a bound in `bar`
|
||||||
--> $DIR/E0631.rs:4:11
|
--> $DIR/E0631.rs:4:11
|
||||||
|
|
|
|
||||||
LL | fn bar<F: Fn<usize>>(_: F) {}
|
LL | fn bar<F: Fn<(usize,)>>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `bar`
|
| ^^^^^^^^^^^^ required by this bound in `bar`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0631.
|
For more information about this error, try `rustc --explain E0631`.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
|
|
||||||
fn f<F: Fn<usize>>(_: F) {}
|
fn f<F: Fn<(usize,)>>(_: F) {}
|
||||||
fn main() {
|
fn main() {
|
||||||
[1, 2, 3].sort_by(|| panic!());
|
[1, 2, 3].sort_by(|| panic!());
|
||||||
//~^ ERROR closure is expected to take
|
//~^ ERROR closure is expected to take
|
||||||
@ -11,9 +11,9 @@ fn main() {
|
|||||||
[1, 2, 3].sort_by(|(tuple, tuple2): (usize, _)| panic!());
|
[1, 2, 3].sort_by(|(tuple, tuple2): (usize, _)| panic!());
|
||||||
//~^ ERROR closure is expected to take
|
//~^ ERROR closure is expected to take
|
||||||
f(|| panic!());
|
f(|| panic!());
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR closure is expected to take
|
||||||
f( move || panic!());
|
f( move || panic!());
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR closure is expected to take
|
||||||
|
|
||||||
let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
|
let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
|
||||||
//~^ ERROR closure is expected to take
|
//~^ ERROR closure is expected to take
|
||||||
|
@ -45,33 +45,41 @@ help: change the closure to take multiple arguments instead of a single tuple
|
|||||||
LL | [1, 2, 3].sort_by(|tuple, tuple2| panic!());
|
LL | [1, 2, 3].sort_by(|tuple, tuple2| panic!());
|
||||||
| ~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
|
||||||
--> $DIR/closure-arg-count.rs:13:5
|
--> $DIR/closure-arg-count.rs:13:5
|
||||||
|
|
|
|
||||||
LL | f(|| panic!());
|
LL | f(|| panic!());
|
||||||
| ^ types differ
|
| ^ -- takes 0 arguments
|
||||||
|
| |
|
||||||
|
| expected closure that takes 1 argument
|
||||||
|
|
|
|
||||||
= note: expected trait `Fn<usize>`
|
|
||||||
found trait `Fn<()>`
|
|
||||||
note: required by a bound in `f`
|
note: required by a bound in `f`
|
||||||
--> $DIR/closure-arg-count.rs:3:9
|
--> $DIR/closure-arg-count.rs:3:9
|
||||||
|
|
|
|
||||||
LL | fn f<F: Fn<usize>>(_: F) {}
|
LL | fn f<F: Fn<(usize,)>>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `f`
|
| ^^^^^^^^^^^^ required by this bound in `f`
|
||||||
|
help: consider changing the closure to take and ignore the expected argument
|
||||||
|
|
|
||||||
|
LL | f(|_| panic!());
|
||||||
|
| ~~~
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
|
||||||
--> $DIR/closure-arg-count.rs:15:5
|
--> $DIR/closure-arg-count.rs:15:5
|
||||||
|
|
|
|
||||||
LL | f( move || panic!());
|
LL | f( move || panic!());
|
||||||
| ^ types differ
|
| ^ ---------- takes 0 arguments
|
||||||
|
| |
|
||||||
|
| expected closure that takes 1 argument
|
||||||
|
|
|
|
||||||
= note: expected trait `Fn<usize>`
|
|
||||||
found trait `Fn<()>`
|
|
||||||
note: required by a bound in `f`
|
note: required by a bound in `f`
|
||||||
--> $DIR/closure-arg-count.rs:3:9
|
--> $DIR/closure-arg-count.rs:3:9
|
||||||
|
|
|
|
||||||
LL | fn f<F: Fn<usize>>(_: F) {}
|
LL | fn f<F: Fn<(usize,)>>(_: F) {}
|
||||||
| ^^^^^^^^^ required by this bound in `f`
|
| ^^^^^^^^^^^^ required by this bound in `f`
|
||||||
|
help: consider changing the closure to take and ignore the expected argument
|
||||||
|
|
|
||||||
|
LL | f( move |_| panic!());
|
||||||
|
| ~~~
|
||||||
|
|
||||||
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
|
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
|
||||||
--> $DIR/closure-arg-count.rs:18:53
|
--> $DIR/closure-arg-count.rs:18:53
|
||||||
@ -190,5 +198,4 @@ LL | fn call<F, R>(_: F) where F: FnOnce() -> R {}
|
|||||||
|
|
||||||
error: aborting due to 14 previous errors
|
error: aborting due to 14 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0593.
|
For more information about this error, try `rustc --explain E0593`.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user