Skip to content
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

Fix for shorter if let lifetime #25

Merged
merged 1 commit into from
Oct 21, 2023
Merged

Fix for shorter if let lifetime #25

merged 1 commit into from
Oct 21, 2023

Conversation

est31
Copy link
Contributor

@est31 est31 commented Oct 21, 2023

Context: Rust compiler PR rust-lang/rust#107251 wants to change the lifetime of things inside the if let matcher. The PR would break the build of this project (out of only a handful of breakages):

error[E0716]: temporary value dropped while borrowed
   --> src/main.rs:343:31
    |
343 |         if let Ok(ref home) = env::var("HOME") { home } else { "$HOME" } );
    |         ----------------------^^^^^^^^^^^^^^^^--------------------------
    |         |                     |                       |
    |         |                     |                       temporary value is freed at the end of this statement
    |         |                     creates a temporary value which is freed while still in use
    |         borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value

The new version compiles both before and after the PR.

@kumavale
Copy link
Owner

I understand the change in lifetime.
Thank you for the PR!

@kumavale kumavale merged commit f536ef9 into kumavale:main Oct 21, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants