about summary refs log tree commit diff
path: root/src/test/ui/suggestions
diff options
context:
space:
mode:
authorArpad Borsos <swatinem@swatinem.de>2022-11-18 22:56:22 +0100
committerArpad Borsos <swatinem@swatinem.de>2022-11-24 10:04:27 +0100
commit9f36f988ad873f5d34cd9c08e4903c597ffc9532 (patch)
tree48825cd5da62cbc7f585c6c991a3b8e25d01dd20 /src/test/ui/suggestions
parentfd815a5091eb4d49cd317f8ad272f17b7a5f550d (diff)
downloadrust-9f36f988ad873f5d34cd9c08e4903c597ffc9532.tar.gz
rust-9f36f988ad873f5d34cd9c08e4903c597ffc9532.zip
Avoid `GenFuture` shim when compiling async constructs
Previously, async constructs would be lowered to "normal" generators,
with an additional `from_generator` / `GenFuture` shim in between to
convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that
async constructs will *directly* implement `Future` without the need
to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation
detail in stack traces and debuginfo, but it can in theory also help
the optimizer as there is less abstractions to see through.
Diffstat (limited to 'src/test/ui/suggestions')
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index 77cef485f30..918d37e6559 100644
--- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -78,20 +78,21 @@ LL | impl<P: Deref<Target: Unpin>> Pin<P> {
 error[E0308]: mismatched types
   --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
    |
-LL |   fn zap() -> BoxFuture<'static, i32> {
-   |               ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
 LL | /     async {
 LL | |         42
 LL | |     }
-   | |_____^ expected struct `Pin`, found opaque type
-   |
-  ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
-   |
-LL |   pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
-   |                                             ------------------------------- the found opaque type
-   |
-   = note:   expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
-           found opaque type `impl Future<Output = {integer}>`
+   | |     ^
+   | |     |
+   | |_____expected struct `Pin`, found `async` block
+   |       arguments to this function are incorrect
+   |
+   = note:     expected struct `Pin<Box<dyn Future<Output = i32> + Send>>`
+           found `async` block `impl Future<Output = {integer}>`
+note: function defined here
+  --> $SRC_DIR/core/src/future/mod.rs:LL:COL
+   |
+LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut {
+   |              ^^^^^^^^^^^^^^^
 help: you need to pin and box this expression
    |
 LL ~     Box::pin(async {