-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I am trying to use TAIT to poll a future constructed by an async fn
, but running into this error, I am unsure where the issue exactly is, would appreciate any guidance
Example Code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b2a9d6f2493a79743f66e7852aeca81a
Error
error[[E0391]](https://doc.rust-lang.org/nightly/error-index.html#E0391): cycle detected when computing type of `BarFuture::{opaque#0}`
--> src/lib.rs:7:18
|
7 | type BarFuture = impl Future<Output = usize> + Send + Sync + 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires type-checking `<impl at src/lib.rs:17:1: 17:11>::bar_project`...
--> src/lib.rs:23:40
|
23 | let bar: &mut BarFuture = &mut self.bar;
| ^^^^
= note: ...which requires evaluating trait selection obligation `core::pin::Pin<&'a mut State>: core::ops::deref::DerefMut`...
= note: ...which again requires computing type of `BarFuture::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> src/lib.rs:1:1
|
1 | / #![feature(type_alias_impl_trait)]
2 | |
3 | | [use std::future::Future;](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b2a9d6f2493a79743f66e7852aeca81a#)
4 | | [use std::pin::Pin;](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b2a9d6f2493a79743f66e7852aeca81a#)
... |
33 | | }
34 | | }
| |_^
Originally posted by @dignifiedquire in #86733 (comment)
We should make cycle errors due to opaque types tell the user about the fact that they can control what's in the defining scope and what isn't
dignifiedquire
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Can do after stabilization