-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[nll] gluon_base
does not compile with NLL
#53119
Comments
OK, the problem here has to do with the "closure region requirements" logic. If look at the closure region requirements from the closure here, we see:
Note that But why are we requiring that? What the closure actually has to prove is something more complicated. It knows that rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs Lines 670 to 679 in cf84056
and we find up with Now, the problem here is that we've introduced a lot more regions than originally existed. In fact, the closure's I've always assumed we'll have to get smarter at some point in this logic but perhaps the time has come. =) The easiest fix, I suspect, is to try to filter out just to the parts that are not satisfied. In particular, we basically want to prove that |
Ugh. That's kind of a pain. Won't get to it today, anyway. |
Having thought about this some I think I was pursuing a fix that would be too hard. Currently, our logic is something like this: We are trying to prove that In order to do that, we first check that the type Then we try to "promote"
and we don't know a good common upper bound for What we should do instead, I think, is to create two bounds for our creator: Note that we can ignore the details from closure body because we know that |
cc @mikhail-m1 -- think you'd be able to take this issue on? |
Here is a guide to the code in question. The following function has the job of "promoting" a failed type test, so that it becomes the creator's obligation to check it: rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs Lines 648 to 654 in 18925de
We begin by promoting the "subject" of the type-test (in this case, the type rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs Lines 665 to 668 in 18925de
Then we compute a "non-local" version of the region
We then push the type-test into the caller's requirements: rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs Lines 681 to 685 in 18925de
Basically what we want to do is to modify that line to instead do something like this: for each free region `r` in `lower_bound` {
let r = self.non_local_universal_upper_bound(r); // typically but not always a no-op
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
subject,
outlived_free_region: r,
blame_span: locations.span(mir),
});
} |
Actually, @nikomatsakis, is there any chance I could give this a try? I've been wanting to start helping out on compiler work for a while, and I like this issue! Assuming you'd have time to lend a hand I'd love to take it! |
@bemeurer sorry, I am already working on it, I think you get ask for a task at https://rust-lang.zulipchat.com, all NLL discussions are there |
@mikhail-m1 No problem! Thank you! |
@bemeurer I just posted an update that includes some links, but please reach out to me on Zulip if you like and we can discuss as well. =) |
Fixes rust-lang#53119. Fixes rust-lang#53119. I minimized sample little bit more, but I checked the sample from issue too. r? @nikomatsakis
Fixes #53119. Fixes #53119. I minimized sample little bit more, but I checked the sample from issue too. r? @nikomatsakis
I reduced a crater run failure of
gluon_base
v0.8.0 to this standalone snippet:this compiles without NLL; with NLL it fails with:
I think this is some kind of failure from the "closure checking" code.
The text was updated successfully, but these errors were encountered: