TAIT: hidden type cannot be another opaque type from the same scope #96406
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
F-type_alias_impl_trait
`#[feature(type_alias_impl_trait)]`
P-low
Low priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I wanted to write a function that statically allocates an
async fn
future: playgroundThis fails with the following error:
One workaround is to move the
Fut
to the top level, but that's undesirable because it makes the entire file to be the defining scope, which interferes with other code.A better workaround suggested by @oli-obk is to wrap the inner future in a "dumb" wrapper, so that the types are no longer equal (the RPIT can't be another opaque type itself, but it can still contain one): playground
First, it would be interesting to see if these "nested opaque types" can be allowed in some cases such as this one.
Second, it would be helpful if the diagnostic suggested the "wrapper" workaround. It would've saved me a lot of time at least :)
See also: Zulip thread
The text was updated successfully, but these errors were encountered: