-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Lambda argument lifetime is tied to lifetime of unrelated iterator #92093
Comments
Worth noting that explicitly declaring the closure as |
This is the minimal example I could come up with https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3703eb374998f226f08fc76b922d112e |
I'm playing around with getting familiar with the MIR, and I have generated it for both a failing version fn main() {
let foo = |a| a+a;
for _ in 0..0 {
let x = 5;
foo(&x);
}
} and a working version which substitutes let foo = |a: &i32| a + a; My understanding of the MIR is extremely rudimentary, but by diffing the only difference in the first MIR files, other than storage allocation, is where in the failing version you have this:
in the working version you have this: version of the "extern rust-call" line
The closures themselves don't have massive differences in the MIR other than allocations and the variable ranges changing. It seems that the bug is happening in the code that figures out what the lifetime of the closure is. This confirms what we had already figured out, but doesn't add much else. Additionally, I can add that it fails during/after the SimplifyCfg step in the MIR generation. I don't know enough to say if that's relevant or not. All the files are attached in the zip, for both the working version and the non-working version, if someone with more knowledge about the MIR wants to have a look. |
@rustbot label +I-prioritize |
It looks like the lifetime of the argument in
str_to_i32
is tied to theline
iterator for some reason, even though they can have different lifetimes:I expect this code to compile. Instead, rustc complains that
Meta
rustc --version --verbose
:Same behavior on both beta and nightly.
(Backtrace is irrelevant here.)
The text was updated successfully, but these errors were encountered: