Closed
Description
I tried this code, playground:
#![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
}
I expected to see this happen: code compiles
Instead, this happened: errors due to name_value.path.segments does not live long enough
It compiles when expressed as nested ifs, playground:
#![feature(let_chains)]
use syn::{Attribute, Meta};
fn f(attr: &Attribute) -> bool {
if let Meta::NameValue(name_value) = attr.parse_meta().ok().unwrap() {
if let path_idents = name_value.path.segments.iter() {}
}
true
}
The code compiled previously, but no longer does after #103034 (confirmed with a cargo bisect-rustc
)
cc @nathanwhit