Open nikomatsakis opened 3 years ago
I'd be interested in taking a stab at this. However, I'm not quite sure what the desired behavior is. I looked at PR https://github.com/rust-lang/rust/pull/66431 which implemented the fallback to a non-defining use for unconstrained opaque types. One possibility would be to somewhere store every location at which such a fallback occurs, to later show a warning/note when no other defining use is found. I would also appreciate some mentoring instructions on how to approach this.
Yea, I think the only way to fix this is to add a new field to https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BorrowCheckResult.html that maps from opaque type def ids to spans and use that when reporting the unconstrained diagnostic.
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 | | }
| |_^
Edit
Sorry, this is likely the wrong issue, but wasn't sure on which of the TAIT issues to post 😅
Sorry, this is likely the wrong issue, but wasn't sure on which of the TAIT issues to post 😅
No worries 😆. If you aren't sure, you can just open a new issue. I'll move your post to a new issue
The minimized example (playground:
gives what appears to me to be the correct error:
but the diagnostics are not very good.
Originally posted by @nikomatsakis in https://github.com/rust-lang/rust/issues/66426#issuecomment-870924733