Pretty print AsyncFn traits too

This commit is contained in:
Michael Goulet 2024-11-11 17:42:35 +00:00
parent 7540306a49
commit 4c53ad5f24
6 changed files with 71 additions and 17 deletions

View file

@ -1,8 +1,8 @@
error[E0277]: the trait bound `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn<()>` is not satisfied
error[E0277]: the trait bound `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn()` is not satisfied
--> $DIR/fn-exception-target-features.rs:16:10
|
LL | test(target_feature);
| ---- ^^^^^^^^^^^^^^ the trait `AsyncFn<()>` is not implemented for fn item `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}`
| ---- ^^^^^^^^^^^^^^ the trait `AsyncFn()` is not implemented for fn item `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}`
| |
| required by a bound introduced by this call
|

View file

@ -1,8 +1,8 @@
error[E0277]: the trait bound `unsafe fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {unsafety}: AsyncFn<()>` is not satisfied
error[E0277]: the trait bound `unsafe fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {unsafety}: AsyncFn()` is not satisfied
--> $DIR/fn-exception.rs:19:10
|
LL | test(unsafety);
| ---- ^^^^^^^^ the trait `AsyncFn<()>` is not implemented for fn item `unsafe fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {unsafety}`
| ---- ^^^^^^^^ the trait `AsyncFn()` is not implemented for fn item `unsafe fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {unsafety}`
| |
| required by a bound introduced by this call
|
@ -12,11 +12,11 @@ note: required by a bound in `test`
LL | fn test(f: impl async Fn()) {}
| ^^^^^^^^^^ required by this bound in `test`
error[E0277]: the trait bound `extern "C" fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {abi}: AsyncFn<()>` is not satisfied
error[E0277]: the trait bound `extern "C" fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {abi}: AsyncFn()` is not satisfied
--> $DIR/fn-exception.rs:20:10
|
LL | test(abi);
| ---- ^^^ the trait `AsyncFn<()>` is not implemented for fn item `extern "C" fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {abi}`
| ---- ^^^ the trait `AsyncFn()` is not implemented for fn item `extern "C" fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {abi}`
| |
| required by a bound introduced by this call
|

View file

@ -0,0 +1,14 @@
//@ edition: 2021
#![feature(async_closure)]
use std::ops::AsyncFnMut;
fn produce() -> impl AsyncFnMut() -> &'static str {
async || ""
}
fn main() {
let x: i32 = produce();
//~^ ERROR mismatched types
}

View file

@ -0,0 +1,17 @@
error[E0308]: mismatched types
--> $DIR/pretty-async-fn-opaque.rs:12:18
|
LL | fn produce() -> impl AsyncFnMut() -> &'static str {
| --------------------------------- the found opaque type
...
LL | let x: i32 = produce();
| --- ^^^^^^^^^ expected `i32`, found opaque type
| |
| expected due to this
|
= note: expected type `i32`
found opaque type `impl AsyncFnMut() -> &'static str`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.