-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Let chain temporaries should drop before else #103248
Comments
Ran into a case that stopped compiling for me after the nightly update, in this case it also didn't compile with the #![feature(let_chains)]
use syn::{Attribute, Meta};
fn f(attr: &Attribute) -> bool {
if let Meta::NameValue(name_value) = attr.parse_meta().ok().unwrap()
&& let path_idents = name_value.path.segments.iter()
/* other stuff */
{
}
true
} |
@Alexendoo that's interesting, and definitely a bug (if you replace it with nested let's it works). I think that's a different issue though than this one. This issue is only about |
👍 opened #103476 |
Okay it seems that lang team members are not a fan of this, so I think I'll close this. If it is fixed, then it should also be fixed for |
@est31 FWIW, given that the let binding isn't in scope in the else branch, it seems hard to imagine a scenario in which an ordinary |
Due to #103034, now the implementation of let chains has changed, to drop temporaries created by
let
after theelse
block terminates. Prior behaviour has mirrored the pre-dropping bheaviour of if as well as bool conditionals in the let chain, while current behaviour mirrorsif let
. However, post-dropping is suboptimal (#103108). In particular, before #103034 this was compiling:But now it doesn't compile any more. I am not adding regression labels because it hasn't affected any of my own code, and it's a nightly feature.
For
if let
it might not be changed any more due to backwards compatibility concerns, but for let chains there are no such concerns as it is a new feature: code is only broken when developers edit it.@rustbot label F-let_chains
The text was updated successfully, but these errors were encountered: