-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Universe errors involving an opaque type results in hallucinations and unused bound vars #124472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Another option would to use syntax from rust-lang/rfcs#3617 and have
|
Wow, this diagnostic isn't great!
I don't think we should use I don't think we use
Similar situation: |
If possible we should probably only suggest that if the failed region obligation/goal was caused by an expression. |
Just to give more context for other readers, the user issue boils down to: #![feature(precise_capturing)]
// `consume_async(async_fn)` passes compilation ✅
fn async_fn<'a>(_: &'a u32) -> impl use<> Future<Output = ()> { async {} }
// `consume_async(async_fn)` fails compilation ❌
fn async_fn<'a>(_: &'a u32) -> impl use<'a> Future<Output = ()> { async {} } |
We do actually use for<> in weird places already. I'm not the biggest fan of it either. in general it's really inconsistent how we print out errors involving higher ranked lifetimes. I think I've seen like three or four different variations lol. |
@rustbot labels +AsyncAwait-Triaged We discussed this in async triage. This seems to be another one of those use cases for async closures. |
If #![feature(precise_capturing, async_closure)]
#![allow(incomplete_features)]
use std::future::Future;
fn main() {
consume_async(async_fn);
}
fn async_fn<'a>(_: &'a u32) -> impl use<'a> Future<Output = ()> { async {} }
fn consume_async(_: impl async FnOnce(&u32) -> ()) {} It seems to me a proper fix for this issue is to stabilize some of these features and then update the error messages to steer people towards those. |
Uh oh!
There was an error while loading. Please reload this page.
Code (Rust ≥2018)
Current output
Desired output
Rationale and extra context
It's very confusing to see a second opaque type and suggestions "to await both futures" (???, there is only one). Ideally we would properly note that the generic can't name the lifetime or something.
Other cases
No response
Rust Version
Anything else?
#124471 has a simiular test case/issue but without the opaque types.
The text was updated successfully, but these errors were encountered: