Open marcospb19 opened 6 months ago
Actually, why doesn't it compile? Idk :)
fn f() -> impl Fn() -> impl Future { ... } // ✅ ok
fn f<H>(h: H) {} // ✅ ok
// Both work, I can do both in the same function // 🤔 mmmmm
fn f<H>(h: H) -> impl Fn() -> impl Future { ... } // ❌ nope
(Maybe the problem source isn't diagnostics?)
Here is another odd example:
fn f<H>() -> impl Fn() -> impl Future<Output = ()> {
g
}
async fn g() {}
Works, now change the expression to a closure:
fn f<H>() -> impl Fn() -> impl Future<Output = ()> {
|| g()
}
And it gives a similar error message, but with this different piece:
error: concrete type differs from previous defining opaque type use
--> src/lib.rs:6:8
|
6 | || g()
| ^^^ expected `impl Future<Output = ()>`, got `impl Future<Output = ()>`
expected impl Future<Output = ()>
got impl Future<Output = ()>
Code
Current output
This error message doesn't mention
<H>
or explain why it is a problem.I tried reproducing the same error message with other chains of
impl
, but I could only reproduce withFnOnce
,Fn
andFnMut
.Rust Version