about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-11-11 17:42:35 +0000
committerMichael Goulet <michael@errs.io>2024-11-22 16:55:28 +0000
commit4c53ad5f244c840049fa706e6e334c1efc19fe7d (patch)
tree132b85990ce3918acbe04f30e9786797506dac0f /tests
parent7540306a4994df05e4aca27130b2757e55000ac7 (diff)
downloadrust-4c53ad5f244c840049fa706e6e334c1efc19fe7d.tar.gz
rust-4c53ad5f244c840049fa706e6e334c1efc19fe7d.zip
Pretty print AsyncFn traits too
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/async-await/async-closures/fn-exception-target-features.stderr4
-rw-r--r--tests/ui/async-await/async-closures/fn-exception.stderr8
-rw-r--r--tests/ui/async-await/async-closures/pretty-async-fn-opaque.rs14
-rw-r--r--tests/ui/async-await/async-closures/pretty-async-fn-opaque.stderr17
4 files changed, 37 insertions, 6 deletions
diff --git a/tests/ui/async-await/async-closures/fn-exception-target-features.stderr b/tests/ui/async-await/async-closures/fn-exception-target-features.stderr
index 396167f4070..e965c40fb5b 100644
--- a/tests/ui/async-await/async-closures/fn-exception-target-features.stderr
+++ b/tests/ui/async-await/async-closures/fn-exception-target-features.stderr
@@ -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
    |
diff --git a/tests/ui/async-await/async-closures/fn-exception.stderr b/tests/ui/async-await/async-closures/fn-exception.stderr
index bacd079af0f..20132e42833 100644
--- a/tests/ui/async-await/async-closures/fn-exception.stderr
+++ b/tests/ui/async-await/async-closures/fn-exception.stderr
@@ -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
    |
diff --git a/tests/ui/async-await/async-closures/pretty-async-fn-opaque.rs b/tests/ui/async-await/async-closures/pretty-async-fn-opaque.rs
new file mode 100644
index 00000000000..2e7cf1b09fd
--- /dev/null
+++ b/tests/ui/async-await/async-closures/pretty-async-fn-opaque.rs
@@ -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
+}
diff --git a/tests/ui/async-await/async-closures/pretty-async-fn-opaque.stderr b/tests/ui/async-await/async-closures/pretty-async-fn-opaque.stderr
new file mode 100644
index 00000000000..863e61eb35a
--- /dev/null
+++ b/tests/ui/async-await/async-closures/pretty-async-fn-opaque.stderr
@@ -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`.