Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WIP: Remove ResumeTy from async lowering #107562

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Feb 1, 2023

Instead of using the stdlib supported ResumeTy, which is being converting to a &mut Context<'_> during the Generator MIR pass, this will use &mut Context<'_> directly in HIR lowering.

It pretty much reverts #105977 and re-applies an updated version of #105250.

This still fails the testcase added in #106264 however, for reasons I don’t understand.

Is blocked on:

@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 1, 2023
@compiler-errors
Copy link
Member

I'm gonna mark this as blocked for now

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 1, 2023
@bors
Copy link
Contributor

bors commented Feb 17, 2023

☔ The latest upstream changes (presumably #108159) made this pull request unmergeable. Please resolve the merge conflicts.

@Swatinem
Copy link
Contributor Author

Now that #107421 has landed, I rebased this, but it is still failing on the testcase in #106264 :-(

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Oct 20, 2023

☔ The latest upstream changes (presumably #116958) made this pull request unmergeable. Please resolve the merge conflicts.

@Swatinem Swatinem force-pushed the async-resumety-v2 branch 2 times, most recently from aa9f535 to 90ef563 Compare December 28, 2023 11:32
@Swatinem
Copy link
Contributor Author

I rebased this again after all the changes to coroutines and gen blocks.

The failing test in tests/ui/async-await/issue-105501.rs yields a wildly differenterror[E0308]: mismatched types now.
Running this with -Znext-solver outputs a much more readable error[E0277]: `{async block@…}` cannot be sent between threads safely.
Though it would obviously be better if it did not error at all :-)

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 28, 2023

☔ The latest upstream changes (presumably #119174) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 16, 2024

☔ The latest upstream changes (presumably #116520) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 6, 2024

☔ The latest upstream changes (presumably #122045) made this pull request unmergeable. Please resolve the merge conflicts.

@Swatinem Swatinem force-pushed the async-resumety-v2 branch from 4fd5a13 to e270344 Compare May 12, 2024 09:58
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 24, 2024

☔ The latest upstream changes (presumably #126784) made this pull request unmergeable. Please resolve the merge conflicts.

@Swatinem Swatinem force-pushed the async-resumety-v2 branch from e270344 to b684ee7 Compare July 30, 2024 13:58
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 2, 2024

☔ The latest upstream changes (presumably #129873) made this pull request unmergeable. Please resolve the merge conflicts.

Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass,
this will use `&mut Context<'_>` directly in HIR lowering.

It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250.

This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#21 exporting to docker image format
#21 sending tarball 28.0s done
#21 DONE 40.7s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
diff of stderr:

5    |                      -- the expected `async` closure body
6 LL |
7 LL |     let () = x();
-    |         ^^   --- this expression has type `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
+    |         ^^   --- this expression has type `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=&'?0 mut Context<'?1> yield_ty=() return_ty=() witness=?6t}`
10    |         expected `async` closure body, found `()`
11    |


-    = note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=ResumeTy yield_ty=() return_ty=() witness=?6t}`
+    = note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=&'?0 mut Context<'?1> yield_ty=() return_ty=() witness=?6t}`
14 
15 error: aborting due to 1 previous error



The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args async-await/async-closures/def-path.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/async-closures/def-path.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/def-path" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zverbose-internals" "--edition=2021"
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/async-closures/def-path.rs:7:9
   |
   |
LL |     let x = async || {};
   |                      -- the expected `async` closure body
LL |     //~^ NOTE the expected `async` closure body
LL |     let () = x();
   |         ^^   --- this expression has type `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=&'?0 mut Context<'?1> yield_ty=() return_ty=() witness=?6t}`
   |         expected `async` closure body, found `()`
   |
   |
   = note: expected `async` closure body `{static main::{closure#0}::{closure#0}<?17t> upvar_tys=?16t resume_ty=&'?0 mut Context<'?1> yield_ty=() return_ty=() witness=?6t}`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
---
diff of stderr:

9 LL | |             x
10 LL | |         };
11    | |_________^ returning this value requires that `'1` must outlive `'2`
+    = note: requirement occurs because of a mutable reference to `Context<'_>`
+    = note: mutable references are invariant over their type parameter
+    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
12 
---
To only update this specific test, also pass `--test-args async-await/async-closures/higher-ranked-return.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/async-closures/higher-ranked-return.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/higher-ranked-return" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/higher-ranked-return/auxiliary" "--edition=2021"
--- stderr -------------------------------
error: lifetime may not live long enough
##[error]  --> /checkout/tests/ui/async-await/async-closures/higher-ranked-return.rs:11:46
   |
   |
LL |           let x = async move |x: &str| -> &str {
   |  ________________________________-________----_^
   | |                                |        |
   | |                                |        return type of async closure `{async closure body@/checkout/tests/ui/async-await/async-closures/higher-ranked-return.rs:11:46: 13:10}` contains a lifetime `'2`
   | |                                let's call the lifetime of this reference `'1`
LL | |         };
LL | |         };
   | |_________^ returning this value requires that `'1` must outlive `'2`
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

---
---- [ui] tests/ui/async-await/async-closures/not-lending.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/not-lending/not-lending.stderr"
diff of stderr:

8    |                 lifetime `'1` represents this closure's body
9    |
10    = note: closure implements `Fn`, so references to captured variables can't escape the closure
+    = note: requirement occurs because of a mutable reference to `Context<'_>`
+    = note: mutable references are invariant over their type parameter
11 
12 error: lifetime may not live long enough
13   --> $DIR/not-lending.rs:16:31


19    |                 lifetime `'1` represents this closure's body
20    |
21    = note: closure implements `Fn`, so references to captured variables can't escape the closure
+    = note: requirement occurs because of a mutable reference to `Context<'_>`
+    = note: mutable references are invariant over their type parameter
22 
23 error: aborting due to 2 previous errors
24 



The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args async-await/async-closures/not-lending.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/async-closures/not-lending.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/not-lending" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/async-closures/not-lending/auxiliary" "--edition=2021"
--- stderr -------------------------------
error: lifetime may not live long enough
##[error]  --> /checkout/tests/ui/async-await/async-closures/not-lending.rs:12:42
   |
   |
LL |         let x = async move || -> &String { &s };
   |                 ------------------------ ^^^^^^ returning this value requires that `'1` must outlive `'2`
   |                 |                |
   |                 |                return type of async closure `{async closure body@/checkout/tests/ui/async-await/async-closures/not-lending.rs:12:42: 12:48}` contains a lifetime `'2`
   |                 lifetime `'1` represents this closure's body
   |
   = note: closure implements `Fn`, so references to captured variables can't escape the closure
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter

error: lifetime may not live long enough
##[error]  --> /checkout/tests/ui/async-await/async-closures/not-lending.rs:16:31
   |
   |
LL |         let x = async move || { &s };
   |                 ------------- ^^^^^^ returning this value requires that `'1` must outlive `'2`
   |                 |           |
   |                 |           return type of async closure `{async closure body@/checkout/tests/ui/async-await/async-closures/not-lending.rs:16:31: 16:37}` contains a lifetime `'2`
   |                 lifetime `'1` represents this closure's body
   |
   = note: closure implements `Fn`, so references to captured variables can't escape the closure
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter

error: aborting due to 2 previous errors
------------------------------------------



---- [ui] tests/ui/async-await/issue-105501.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issue-105501.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-105501" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/async-await/issue-105501.rs:25:5
   |
   |
LL |               .then(|_| async {})
   |                         |
   |                         the expected `async` block
   |                         the found `async` block
...
...
LL | /     is_send(async move {
LL | |         let _: Option<()> = fut.await;
   | |______^ one type is more general than the other
   |
   |
   = note: expected `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
              found `async` block `{async block@/checkout/tests/ui/async-await/issue-105501.rs:17:23: 17:28}`
   = note: no two async blocks, even if identical, have the same type
   = help: consider pinning your async block and casting it to a trait object
  --> /checkout/tests/ui/async-await/issue-105501.rs:12:20
   |
   |
LL | fn is_send(_: impl Send) {}
   |                    ^^^^
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0308`.
------------------------------------------
---
To only update this specific test, also pass `--test-args async-await/issue-69446-fnmut-capture.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issue-69446-fnmut-capture.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-69446-fnmut-capture" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
--- stderr -------------------------------
error: captured variable cannot escape `FnMut` closure body
##[error]  --> /checkout/tests/ui/async-await/issue-69446-fnmut-capture.rs:19:17
   |
   |
LL |       let mut x = Foo;
   |           ----- variable defined here
LL |       bar(move || async { //~ ERROR captured
   |  _______________-_^
   | |               inferred to be a `FnMut` closure
LL | |         x.foo();
   | |         - variable captured here
LL | |     });
LL | |     });
   | |_____^ returns an `async` block that contains a reference to a captured variable, which then escapes the closure body
   = note: `FnMut` closures only have access to their captured variables while they are executing...
   = note: ...therefore, they cannot allow references to captured variables to escape
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter
---
---- [ui] tests/ui/async-await/issue-74072-lifetime-name-annotations.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-74072-lifetime-name-annotations/issue-74072-lifetime-name-annotations.stderr"
diff of stderr:

40    | |_____^ returning this value requires that `'1` must outlive `'2`
42    = note: closure implements `FnMut`, so references to captured variables can't escape the closure
+    = note: requirement occurs because of a mutable reference to `Context<'_>`
+    = note: mutable references are invariant over their type parameter
+    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
43 
44 error[E0716]: temporary value dropped while borrowed
45   --> $DIR/issue-74072-lifetime-name-annotations.rs:13:5

89    | |_____^ returning this value requires that `'1` must outlive `'2`
91    = note: closure implements `FnMut`, so references to captured variables can't escape the closure
+    = note: requirement occurs because of a mutable reference to `Context<'_>`
+    = note: mutable references are invariant over their type parameter
+    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
---
To only update this specific test, also pass `--test-args async-await/issue-74072-lifetime-name-annotations.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/issue-74072-lifetime-name-annotations" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
--- stderr -------------------------------
--- stderr -------------------------------
error[E0506]: cannot assign to `*x` because it is borrowed
   |
LL | pub async fn async_fn(x: &mut i32) -> &i32 {
   |                          - let's call the lifetime of this reference `'1`
LL |     let y = &*x;
LL |     let y = &*x;
   |             --- `*x` is borrowed here
LL |     *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
   |     ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL |     y
   |     - returning this value requires that `*x` is borrowed for `'1`

error[E0506]: cannot assign to `*x` because it is borrowed
   |
LL |     (async move || {
   |                  - return type of async closure is &'1 i32
...
...
LL |         let y = &*x;
   |                 --- `*x` is borrowed here
LL |         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
   |         ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL |         y
   |         - returning this value requires that `*x` is borrowed for `'1`
error: lifetime may not live long enough
##[error]  --> /checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:13:20
   |
LL |       (async move || {
LL |       (async move || {
   |  ______-------------_^
   | |      |           |
   | |      |           return type of async closure `{async closure body@/checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:13:20: 19:6}` contains a lifetime `'2`
   | |      lifetime `'1` represents this closure's body
LL | |         //~^ ERROR lifetime may not live long enough
LL | |         //~| ERROR temporary value dropped while borrowed
LL | |         let y = &*x;
LL | |         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
LL | |     })()
LL | |     })()
   | |_____^ returning this value requires that `'1` must outlive `'2`
   = note: closure implements `FnMut`, so references to captured variables can't escape the closure
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error[E0716]: temporary value dropped while borrowed
##[error]  --> /checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:13:5
   |
LL |    pub fn async_closure(x: &mut i32) -> impl Future<Output=&i32> {
   |                            - let's call the lifetime of this reference `'1`
LL | //     (async move || {
LL | ||         //~^ ERROR lifetime may not live long enough
LL | ||         //~| ERROR temporary value dropped while borrowed
LL | ||         let y = &*x;
LL | ||         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
LL | ||     })()
LL | ||     })()
   | ||______^_- argument requires that borrow lasts for `'1`
   |         creates a temporary value which is freed while still in use
LL |    }
   |    - temporary value is freed at the end of this statement


error[E0506]: cannot assign to `*x` because it is borrowed
   |
   |
LL |     (async move || -> &i32 {
   |                          - return type of async closure is &'1 i32
LL |         let y = &*x;
LL |         let y = &*x;
   |                 --- `*x` is borrowed here
LL |         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
   |         ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL |         y
   |         - returning this value requires that `*x` is borrowed for `'1`
error: lifetime may not live long enough
##[error]  --> /checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:23:28
   |
   |
LL |       (async move || -> &i32 {
   |  ______---------------------_^
   | |      |                |
   | |      |                return type of async closure `{async closure body@/checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:23:28: 29:6}` contains a lifetime `'2`
   | |      lifetime `'1` represents this closure's body
LL | |         //~^ ERROR lifetime may not live long enough
LL | |         //~| ERROR temporary value dropped while borrowed
LL | |         let y = &*x;
LL | |         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
LL | |     })()
LL | |     })()
   | |_____^ returning this value requires that `'1` must outlive `'2`
   = note: closure implements `FnMut`, so references to captured variables can't escape the closure
   = note: requirement occurs because of a mutable reference to `Context<'_>`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error[E0716]: temporary value dropped while borrowed
##[error]  --> /checkout/tests/ui/async-await/issue-74072-lifetime-name-annotations.rs:23:5
   |
LL |    pub fn async_closure_explicit_return_type(x: &mut i32) -> impl Future<Output=&i32> {
   |                                                 - let's call the lifetime of this reference `'1`
LL | //     (async move || -> &i32 {
LL | ||         //~^ ERROR lifetime may not live long enough
LL | ||         //~| ERROR temporary value dropped while borrowed
LL | ||         let y = &*x;
LL | ||         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
LL | ||     })()
LL | ||     })()
   | ||______^_- argument requires that borrow lasts for `'1`
   |         creates a temporary value which is freed while still in use
LL |    }
   |    - temporary value is freed at the end of this statement


error[E0506]: cannot assign to `*x` because it is borrowed
   |
LL |     async move {
   |              - return type of async block is &'1 i32
LL |         let y = &*x;
LL |         let y = &*x;
   |                 --- `*x` is borrowed here
LL |         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
   |         ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL |         y
   |         - returning this value requires that `*x` is borrowed for `'1`
error: aborting due to 8 previous errors

Some errors have detailed explanations: E0506, E0716.
For more information about an error, try `rustc --explain E0506`.
---
+ 
+ error: unreachable statement
+   --> $DIR/unreachable-lint-2.rs:7:5
+    |
+ LL |     endless().await;
+ LL |     println!("this is unreachable!");
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
+    |
14    = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
---
-   --> /checkout/tests/ui/async-await/unreachable-lint-2.rs:3:9
+ error: unreachable expression
+   --> $DIR/unreachable-lint-2.rs:6:5
+    |
+ LL |     endless().await;
+    |     |
+    |     unreachable expression
+    |     any code following this expression is unreachable
+    |
---
To only update this specific test, also pass `--test-args async-await/unreachable-lint-2.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/async-await/unreachable-lint-2.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/async-await/unreachable-lint-2" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
--- stderr -------------------------------
error: unreachable expression
##[error]  --> /checkout/tests/ui/async-await/unreachable-lint-2.rs:6:5
   |

@bors
Copy link
Contributor

bors commented Feb 6, 2025

☔ The latest upstream changes (presumably #136471) made this pull request unmergeable. Please resolve the merge conflicts.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants