-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
"computing type of ...::{opaque#0}" query cycle in async fn
w/ auto trait obligations.
#104343
Comments
Note that this a cycle between type-checking and resolving an
( Sadly the rest of the cycle is irrelevant and could ideally be cut out - part of the problem is cc @oli-obk |
It's likely all the auto-trait bounds you have ( fn require_sync<T: Sync>(_: T) {}
fn test() -> impl Copy {
if false { require_sync(test()); }
123
}
|
It is, in fact, So this has nothing to do with GATs, it's just perhaps not the kind of code you'd write without GATs. EDIT: conversely, removing auto trait bounds but keeping GATs makes the original example compile. |
async fn
w/ auto trait obligations.
Wow, thanks for the analysis here @eddyb! This is a tough one. We essentially need to recognize coinductive cycles across queries. Or, we have to delay checking the bounds of
(I don't this problem can compile, because we should never be able to figure out what |
@jackh726 it should be possible to delay checking bounds if they don't affect the return type of the function, right? First infer the return type as i32, then check the Send bound? I agree your code can't compile, but I think eddyb's MCVE should be possible in theory. |
I think one of my early implementations actually solved this problem, but in a way that I don't trust to be sound wrt queries (esp. incrementally) - all it did is really just defer such obligations as much as possible (into Maybe a sound way to do this would be to put the obligations in the result of However, a more immediate issue: #104343 (comment) contains, in the query cycle (tho at the bottom, maybe this should be reversed to look more like a backtrace?) the actual bound that caused the problem, so at least the user can guess something from it. Someone should investigate how a similar thing doesn't get triggered for the example in this issue (interaction with |
I tried this code using GATs and the async feature
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8856ef117840a1d3b4be93441c2b36b1
I expected it to compile. For reference, the same code implemented using manual
.then
future chaining compiles as shown here:https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8cd834a4ff4d4b969d6ba1de9db91fee
Note that the above are built with nightly 1.67, but the same error occurs on stable 1.65.
Tagging @jackh726 as suggested by @jyn514
Note that GATs are an amazing feature that I'm incredibly grateful to you for implementing, and also that I'm not surprised that my extremely galaxy brained Haskell shenanigans hit some edge case.
EDIT(@eddyb): changed title as per #104343 (comment) - this does not seem to involve GATs at all, just the unfortunate interaction of
async fn
's-> impl Future
desugaring + the "leaky" auto trait semantics of-> impl Trait
.The text was updated successfully, but these errors were encountered: