Skip to content

tests: Add regression test for async closures involving HRTBs#154109

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:unifying-function-types-involving-hrtb
Mar 20, 2026
Merged

tests: Add regression test for async closures involving HRTBs#154109
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:unifying-function-types-involving-hrtb

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Mar 19, 2026

I suspect the original code from #59337 had several problems. The last problem fixed that made the code compile entered nightly-2024-02-11. The code fails to build with nightly-2024-02-10:

$ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
  --> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
   |
31 |     foo(async move | f: &u8 | { *f });
   |     --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
   |     |
   |     required by a bound introduced by this call
   |

(Note that you must add #![feature(async_closure)] to test with such old nightlies, since they are from before stabilization of async closures.)

So one of the following commits made the code build:

git log d44e3b9..6cc4843 --no-merges --oneline

4def373 manually bless an aarch64 test
04bc624 rebless after rebase
77f8c3c detect consts that reference extern statics
9c0623f validation: descend from consts into statics
4e77e36 unstably allow constants to refer to statics and read from immutable statics
a2479a4 Remove unnecessary min_specialization after bootstrap
7b73e4f Allow restricted trait impls in macros with min_specialization
e6f5af9 Remove unused fn
fde695a Add a helpful suggestion
d7263d7 Change wording
973bbfb No more associated type bounds in dyn trait
cf1096e Remove unnecessary #![feature(min_specialization)]
3d4a9f5 Turn the "no saved object file in work product" ICE into a translatable fatal error
bb60ded Loosen an assertion to account for stashed errors.
69a5264 Move some tests
4ef1790 tidy
e59d9b1 Avoid a collection and iteration on empty passes
8b6b9c5 ast_lowering: Fix regression in use ::{} imports.
83f3bc4 Update jobserver-rs to 0.1.28
14e0dab Unify item relative path computation in one function
f3c2483 Add regression test for non local items link generation
f0d002b Correctly generate path for non-local items in source code pages
c94bbb2 Clarify that atomic and regular integers can differ in alignment
7057188 make it recursive
7a63d3f Add tests for untested capabilities
548929d Don't unnecessarily lower associated type bounds to impl trait
22d582a For a rigid projection, recursively look at the self type's item bounds
540be28 sort suggestions for object diagnostic
9322882 Add a couple more tests
3bb384a Prefer AsyncFn* over Fn* for coroutine-closures
aa6f45e Use ensure when the result of the query is not needed beyond its Resultness
8ff1994 Fix whitespace issues that tidy caught
f0c6f5a Add documentation on str::starts_with
63cc3c7 test llvm_out behaviour
7fb4512 fix llvm_out to use the correct LLVM root
b8c93f1 Coroutine closures implement regular Fn traits, when possible
08af64e Regular closures now built-in impls for AsyncFn*
0dd4078 Harmonize blanket implementations for AsyncFn* traits
f3d32f2 Flatten confirmation logic
9a819ab static mut: allow reference to arbitrary types, not just slices and arrays

This was probably fixed by 3bb384a (#120712). That PR does not have a big tests diff, so I assume the test we add does not exist elsewhere. It's hard to know for sure.

Closes #59337 since we add the test from that issue. In that issue there is a proposal for two minimized versions, but they both fail to compile with nightly-2024-02-11, so those reproducers are for different problem(s).

Tracking Issue

I suspect the original code had several issues. The last one that made
the code compile entered `nightly-2024-02-11`. The code fails to build
with `nightly-2024-02-10`:

    $ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
    error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
      --> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
       |
    31 |     foo(async move | f: &u8 | { *f });
       |     --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
       |     |
       |     required by a bound introduced by this call
       |

(Note that you must add `#![feature(async_closure)]` to test with such
old nightlies, since they are from before stabilization of async
closures.)

This was probably fixed by 3bb384a.
@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. labels Mar 19, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 15 candidates

@jackh726
Copy link
Member

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

📌 Commit caad6ee has been approved by jackh726

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 19, 2026
@Kivooeo Kivooeo assigned jackh726 and unassigned Kivooeo Mar 19, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 19, 2026
…volving-hrtb, r=jackh726

tests: Add regression test for async closures involving HRTBs

I suspect the original code from rust-lang#59337 had several problems. The last problem fixed that made the code compile entered `nightly-2024-02-11`. The code fails to build with `nightly-2024-02-10`:

    $ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
    error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
      --> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
       |
    31 |     foo(async move | f: &u8 | { *f });
       |     --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
       |     |
       |     required by a bound introduced by this call
       |

(Note that you must add `#![feature(async_closure)]` to test with such old nightlies, since they are from before stabilization of async closures.)

So one of the following commits made the code build:

<details>

<summary>git log d44e3b9..6cc4843  --no-merges --oneline</summary>

4def373 manually bless an aarch64 test
04bc624 rebless after rebase
77f8c3c detect consts that reference extern statics
9c0623f validation: descend from consts into statics
4e77e36 unstably allow constants to refer to statics and read from immutable statics
a2479a4 Remove unnecessary `min_specialization` after bootstrap
7b73e4f Allow restricted trait impls in macros with `min_specialization`
e6f5af9 Remove unused fn
fde695a Add a helpful suggestion
d7263d7 Change wording
973bbfb No more associated type bounds in dyn trait
cf1096e Remove unnecessary `#![feature(min_specialization)]`
3d4a9f5 Turn the "no saved object file in work product" ICE into a translatable fatal error
bb60ded Loosen an assertion to account for stashed errors.
69a5264 Move some tests
4ef1790 tidy
e59d9b1 Avoid a collection and iteration on empty passes
8b6b9c5 ast_lowering: Fix regression in `use ::{}` imports.
83f3bc4 Update jobserver-rs to 0.1.28
14e0dab Unify item relative path computation in one function
f3c2483 Add regression test for non local items link generation
f0d002b Correctly generate path for non-local items in source code pages
c94bbb2 Clarify that atomic and regular integers can differ in alignment
7057188 make it recursive
7a63d3f Add tests for untested capabilities
548929d Don't unnecessarily lower associated type bounds to impl trait
22d582a For a rigid projection, recursively look at the self type's item bounds
540be28 sort suggestions for object diagnostic
9322882 Add a couple more tests
3bb384a Prefer AsyncFn* over Fn* for coroutine-closures
aa6f45e Use `ensure` when the result of the query is not needed beyond its `Result`ness
8ff1994 Fix whitespace issues that tidy caught
f0c6f5a Add documentation on `str::starts_with`
63cc3c7 test `llvm_out` behaviour
7fb4512 fix `llvm_out` to use the correct LLVM root
b8c93f1 Coroutine closures implement regular Fn traits, when possible
08af64e Regular closures now built-in impls for AsyncFn*
0dd4078 Harmonize blanket implementations for AsyncFn* traits
f3d32f2 Flatten confirmation logic
9a819ab static mut: allow reference to arbitrary types, not just slices and arrays

</details>

This was probably fixed by 3bb384a (rust-lang#120712). That PR does not have a big tests diff, so I assume the test we add does not exist elsewhere. It's hard to know for sure.

Closes rust-lang#59337 since we add the test from that issue. In that issue there is a [proposal](rust-lang#59337 (comment)) for two minimized versions, but they both fail to compile with `nightly-2024-02-11`, so those reproducers are for different problem(s).

### Tracking Issue
- rust-lang#62290
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 19, 2026
…volving-hrtb, r=jackh726

tests: Add regression test for async closures involving HRTBs

I suspect the original code from rust-lang#59337 had several problems. The last problem fixed that made the code compile entered `nightly-2024-02-11`. The code fails to build with `nightly-2024-02-10`:

    $ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
    error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
      --> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
       |
    31 |     foo(async move | f: &u8 | { *f });
       |     --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
       |     |
       |     required by a bound introduced by this call
       |

(Note that you must add `#![feature(async_closure)]` to test with such old nightlies, since they are from before stabilization of async closures.)

So one of the following commits made the code build:

<details>

<summary>git log d44e3b9..6cc4843  --no-merges --oneline</summary>

4def373 manually bless an aarch64 test
04bc624 rebless after rebase
77f8c3c detect consts that reference extern statics
9c0623f validation: descend from consts into statics
4e77e36 unstably allow constants to refer to statics and read from immutable statics
a2479a4 Remove unnecessary `min_specialization` after bootstrap
7b73e4f Allow restricted trait impls in macros with `min_specialization`
e6f5af9 Remove unused fn
fde695a Add a helpful suggestion
d7263d7 Change wording
973bbfb No more associated type bounds in dyn trait
cf1096e Remove unnecessary `#![feature(min_specialization)]`
3d4a9f5 Turn the "no saved object file in work product" ICE into a translatable fatal error
bb60ded Loosen an assertion to account for stashed errors.
69a5264 Move some tests
4ef1790 tidy
e59d9b1 Avoid a collection and iteration on empty passes
8b6b9c5 ast_lowering: Fix regression in `use ::{}` imports.
83f3bc4 Update jobserver-rs to 0.1.28
14e0dab Unify item relative path computation in one function
f3c2483 Add regression test for non local items link generation
f0d002b Correctly generate path for non-local items in source code pages
c94bbb2 Clarify that atomic and regular integers can differ in alignment
7057188 make it recursive
7a63d3f Add tests for untested capabilities
548929d Don't unnecessarily lower associated type bounds to impl trait
22d582a For a rigid projection, recursively look at the self type's item bounds
540be28 sort suggestions for object diagnostic
9322882 Add a couple more tests
3bb384a Prefer AsyncFn* over Fn* for coroutine-closures
aa6f45e Use `ensure` when the result of the query is not needed beyond its `Result`ness
8ff1994 Fix whitespace issues that tidy caught
f0c6f5a Add documentation on `str::starts_with`
63cc3c7 test `llvm_out` behaviour
7fb4512 fix `llvm_out` to use the correct LLVM root
b8c93f1 Coroutine closures implement regular Fn traits, when possible
08af64e Regular closures now built-in impls for AsyncFn*
0dd4078 Harmonize blanket implementations for AsyncFn* traits
f3d32f2 Flatten confirmation logic
9a819ab static mut: allow reference to arbitrary types, not just slices and arrays

</details>

This was probably fixed by 3bb384a (rust-lang#120712). That PR does not have a big tests diff, so I assume the test we add does not exist elsewhere. It's hard to know for sure.

Closes rust-lang#59337 since we add the test from that issue. In that issue there is a [proposal](rust-lang#59337 (comment)) for two minimized versions, but they both fail to compile with `nightly-2024-02-11`, so those reproducers are for different problem(s).

### Tracking Issue
- rust-lang#62290
rust-bors bot pushed a commit that referenced this pull request Mar 20, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152909 (sess: `-Zbranch-protection` is a target modifier)
 - #153556 (`impl` restriction lowering)
 - #154048 (Don't emit rustdoc `missing_doc_code_examples` lint on impl items)
 - #153992 (bootstrap: Optionally print a backtrace if a command fails)
 - #154019 (two smaller feature cleanups)
 - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`)
 - #154075 (Rewrite `query_ensure_result`.)
 - #154082 (Updates derive_where and removes workaround)
 - #154084 (Preserve braces around `self` in use tree pretty printing)
 - #154086 (Insert space after float literal ending with `.` in pretty printer)
 - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
 - #154109 (tests: Add regression test for async closures involving HRTBs)
rust-bors bot pushed a commit that referenced this pull request Mar 20, 2026
Rollup of 15 pull requests

Successful merges:

 - #152909 (sess: `-Zbranch-protection` is a target modifier)
 - #153556 (`impl` restriction lowering)
 - #154048 (Don't emit rustdoc `missing_doc_code_examples` lint on impl items)
 - #150935 (Introduce #[diagnostic::on_move(message)])
 - #152973 (remove -Csoft-float)
 - #153862 (Rename `cycle_check` to `find_cycle`)
 - #153992 (bootstrap: Optionally print a backtrace if a command fails)
 - #154019 (two smaller feature cleanups)
 - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`)
 - #154075 (Rewrite `query_ensure_result`.)
 - #154082 (Updates derive_where and removes workaround)
 - #154084 (Preserve braces around `self` in use tree pretty printing)
 - #154086 (Insert space after float literal ending with `.` in pretty printer)
 - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
 - #154109 (tests: Add regression test for async closures involving HRTBs)
@rust-bors rust-bors bot merged commit ffe94f0 into rust-lang:main Mar 20, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

closures with async blocks have concrete argument lifetimes

4 participants