Rollup merge of #136414 - estebank:expected-return-type, r=oli-obk
Shorten error message for callable with wrong return type ``` error: expected `{closure@...}` to return `Ret`, but it returns `Other` ``` instead of ``` error: expected `{closure@...}` to be a closure that returns `Ret`, but it returns `Other` ```
This commit is contained in:
commit
dc4d38740e
23 changed files with 29 additions and 31 deletions
|
@ -1,4 +1,4 @@
|
|||
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
|
||||
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
|
||||
--> $DIR/is-not-fn.rs:8:14
|
||||
|
|
||||
LL | needs_fn(async || {});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
|
||||
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
|
||||
--> $DIR/is-not-fn.rs:8:14
|
||||
|
|
||||
LL | needs_fn(async || {});
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
fn main() {
|
||||
fn needs_fn(x: impl FnOnce()) {}
|
||||
needs_fn(async || {});
|
||||
//~^ ERROR expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`
|
||||
//~^ ERROR expected `{async closure@is-not-fn.rs:8:14}` to return `()`
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ LL | true
|
|||
= note: expected enum `Option<()>`
|
||||
found type `bool`
|
||||
|
||||
error[E0271]: expected `{closure@dont-ice-for-type-mismatch-in-closure-in-async.rs:6:10}` to be a closure that returns `bool`, but it returns `Option<()>`
|
||||
error[E0271]: expected `{closure@dont-ice-for-type-mismatch-in-closure-in-async.rs:6:10}` to return `bool`, but it returns `Option<()>`
|
||||
--> $DIR/dont-ice-for-type-mismatch-in-closure-in-async.rs:6:16
|
||||
|
|
||||
LL | call(|| -> Option<()> {
|
||||
|
|
|
@ -43,8 +43,8 @@ impl Runtime {
|
|||
fn main() {
|
||||
Runtime.block_on(async {
|
||||
StructAsync { callback }.await;
|
||||
//~^ ERROR expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
//~| ERROR expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
//~| ERROR expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
//~^ ERROR expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
//~| ERROR expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
//~| ERROR expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0271]: expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
error[E0271]: expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
--> $DIR/issue-98634.rs:45:23
|
||||
|
|
||||
LL | StructAsync { callback }.await;
|
||||
|
@ -10,7 +10,7 @@ note: required by a bound in `StructAsync`
|
|||
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`
|
||||
|
||||
error[E0271]: expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
error[E0271]: expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
--> $DIR/issue-98634.rs:45:9
|
||||
|
|
||||
LL | StructAsync { callback }.await;
|
||||
|
@ -22,7 +22,7 @@ note: required by a bound in `StructAsync`
|
|||
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`
|
||||
|
||||
error[E0271]: expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
error[E0271]: expected `callback` to return `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
|
||||
--> $DIR/issue-98634.rs:45:34
|
||||
|
|
||||
LL | StructAsync { callback }.await;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue