-
Notifications
You must be signed in to change notification settings - Fork 0
normalizing in writeback causes cycle errors with generators #82
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
I see a few solutions for this problem:
|
my initial vibe is to normalize in writeback before instantiating the witness infer var and accept ambiguous obligations in |
This concerns me a bit, since we're now breaking two invariants in both deeply normalize and writeback:
The fact that we stall obligations on an infer var and draining them feels ad-hoc, and it suggests to me that the solver should be taught about this generator witness stalling first-class, the same way it knows about opaques in a first-class way. |
It still shouldn't, it would be: deeply-normalize -> instantiate-witness-infer -> writeback
It is not ideal 🤔 for me the core invariant is that we don't leave some projection which can be later normalized. So erroring of the term infer var is unconstrained but accepting the projection goal itself to be ambig seems fine to me. I guess this could cause issues if a wf project goal actually manages to result in constraints but later still does not hold. I think it's kind of an invariant that that doesn't happen once we cover impls using param env candidates. I think we currently have the defacto invariant: if a
I agree that it is adhoc, however, given that hir typeck and mir build are separate queries, I personally think it's fairly clean. in a sense writeback is really just a deep
I disagree quite strongly here. The witness being an infer var is the first-class way to tell the solver that it should stall. |
That seems really annoying to handle:
|
Thoughts:
Making the typing mode larger is a bit concerning. Maybe we should put the opaques and the coroutines into the same list together? |
affected ui tests:
|
I just realized. The only way we should encounter generators which are not from the current function is by leaking auto traits of an opaque. We could probably get away with simply always stalling on generators during analysis 🤔 |
I think this would cause us to stall way more obligations than we want to. |
my point is (if we have a typing mode only used during hir typeck), this would only additionally stall on generators leaked as part of opaque type auto trait leakage. I don't believe that stalling on this should be in any way problematic. I believe that I am generally less worried about stalling on more obligations than u are though |
fixed by rust-lang/rust#138845 |
We normalize types during writeback resolve:
https://github.com/rust-lang/rust/blob/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/compiler/rustc_hir_typeck/src/writeback.rs#L790-L794
When normalizing types, this may cause us to try to prove an auto trait bound on a generator witness that is local to the body:
From #82 (comment) this should probably be fixed by extending
TypingMode::Analysis
to also track the generator witnesses of the current function.The text was updated successfully, but these errors were encountered: