mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #154109 - Enselic:unifying-function-types-involving-hrtb, r=jackh726
tests: Add regression test for async closures involving HRTBs I suspect the original code from rust-lang/rust#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 d44e3b95cb9d4..6cc4843512d613f --no-merges --oneline</summary>4def37386cmanually bless an aarch64 test04bc624ea0rebless after rebase77f8c3caeadetect consts that reference extern statics9c0623fe8fvalidation: descend from consts into statics4e77e368ebunstably allow constants to refer to statics and read from immutable staticsa2479a4ae7Remove unnecessary `min_specialization` after bootstrap7b73e4fd44Allow restricted trait impls in macros with `min_specialization`e6f5af9671Remove unused fnfde695a2d1Add a helpful suggestiond7263d7aadChange wording973bbfbd23No more associated type bounds in dyn traitcf1096eb72Remove unnecessary `#![feature(min_specialization)]`3d4a9f5047Turn the "no saved object file in work product" ICE into a translatable fatal errorbb60ded24bLoosen an assertion to account for stashed errors.69a5264a52Move some tests4ef1790b4etidye59d9b171eAvoid a collection and iteration on empty passes8b6b9c5efcast_lowering: Fix regression in `use ::{}` imports.83f3bc4271Update jobserver-rs to 0.1.2814e0dab96bUnify item relative path computation in one functionf3c24833c5Add regression test for non local items link generationf0d002b890Correctly generate path for non-local items in source code pagesc94bbb24dbClarify that atomic and regular integers can differ in alignment7057188c54make it recursive7a63d3f16aAdd tests for untested capabilities548929dc5eDon't unnecessarily lower associated type bounds to impl trait22d582a38dFor a rigid projection, recursively look at the self type's item bounds540be28f6csort suggestions for object diagnostic9322882adeAdd a couple more tests3bb384aad6Prefer AsyncFn* over Fn* for coroutine-closuresaa6f45eb79Use `ensure` when the result of the query is not needed beyond its `Result`ness8ff1994ec0Fix whitespace issues that tidy caughtf0c6f5a7feAdd documentation on `str::starts_with`63cc3c7b8ftest `llvm_out` behaviour7fb4512ee8fix `llvm_out` to use the correct LLVM rootb8c93f1223Coroutine closures implement regular Fn traits, when possible08af64e96bRegular closures now built-in impls for AsyncFn*0dd40786b5Harmonize blanket implementations for AsyncFn* traitsf3d32f2f0cFlatten confirmation logic9a819ab8f7static mut: allow reference to arbitrary types, not just slices and arrays </details> This was probably fixed by3bb384aad6(https://github.com/rust-lang/rust/pull/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/rust#59337 since we add the test from that issue. In that issue there is a [proposal](https://github.com/rust-lang/rust/issues/59337#issuecomment-826441716) 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 - https://github.com/rust-lang/rust/issues/62290
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//! Regresssion test for <https://github.com/rust-lang/rust/issues/59337>.
|
||||
|
||||
//@ edition:2018
|
||||
//@ check-pass
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
trait Foo<'a> {
|
||||
type Future: Future<Output = u8> + 'a;
|
||||
|
||||
fn start(self, f: &'a u8) -> Self::Future;
|
||||
}
|
||||
|
||||
impl<'a, Fn, Fut> Foo<'a> for Fn
|
||||
where
|
||||
Fn: FnOnce(&'a u8) -> Fut,
|
||||
Fut: Future<Output = u8> + 'a,
|
||||
{
|
||||
type Future = Fut;
|
||||
|
||||
fn start(self, f: &'a u8) -> Self::Future { (self)(f) }
|
||||
}
|
||||
|
||||
fn foo<F>(f: F) where F: for<'a> Foo<'a> {
|
||||
let bar = 5;
|
||||
f.start(&bar);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo(async move | f: &u8 | { *f });
|
||||
|
||||
foo({ async fn baz(f: &u8) -> u8 { *f } baz });
|
||||
}
|
||||
Reference in New Issue
Block a user