-
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
librustc_mir/borrow_check/nll/universal_regions.rs:824: cannot convert ReFree ... #51351
Comments
Self contained example #![feature(nll)]
fn produce<'a>()
{
move || {
let x: &'a () = &();
};
}
fn main() {} |
no need for a move, or closure, just the let expression already ICE's #![feature(nll)]
fn crash<'a>() {
let x: &'a () = &();
}
fn main() {} |
Alternative repro taken from #51676: #![feature(nll)]
fn crash<'a>() {
let x: &'a str = "?";
}
fn main() {} |
High priority, blocks bootstrap too |
OK, so, I remember this problem. It's a pain in the neck, but we gotta fix it. The problem is that we categorize rust/src/librustc/middle/resolve_lifetime.rs Lines 2481 to 2483 in 860d169
However, the actual definition used in the code is a bit broader: rust/src/librustc/middle/resolve_lifetime.rs Lines 2548 to 2558 in 860d169
The reason that being late-bound makes a difference is because of how the universal regions code tries to instantiate and find all the lifetime parameters. It begins by looking the "generics" for the function: those include the early-bound regions. Then it instantiates all the remaining free regions that appear in the argument types -- that is supposed to capture the late-bound regions. But for a region like The rust/src/librustc/middle/resolve_lifetime.rs Lines 195 to 215 in 860d169
In particular, the rust/src/librustc/middle/resolve_lifetime.rs Lines 207 to 210 in 860d169
This can be accessed via the (Annoyingly, that field doesn't contain all late-bound regions -- only the named ones. Anonymous ones are found later, during type conversion.) What we would have to do is extend the rust/src/librustc_mir/borrow_check/nll/universal_regions.rs Lines 458 to 463 in 860d169
After this step, we need to load the full set of named, late-bound regions and then check for each of them whether they were found amongst the types -- or maybe we should just add a new field to the |
OK, that was a first round of mentoring instructions, but there are maybe 50% notes to myself and not necessarily expected to be understood. Still, nominating for this week, and I can try to leave better notes. |
look at it |
So @mikhail-m1 I was looking over this issue again and it occurs to me that I think that the bug in the original issue may not be solved by my proposed fix (though some of the minimizations will be, I think). I'm going to look a bit into that and maybe split off a second issue with a different minimization. |
fix simple case of issue #51351 and #52133 r? @nikomatsakis
Should be fixed now |
NLL
I tried this code:
I expected to see this happen: To not cause panic in the compiler.
Instead, this happened: Panic.
These are the enabled features:
Meta
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: