Closed
Description
I tried this code: playground
struct LoudDrop(&'static str);
impl Drop for LoudDrop {
fn drop(&mut self) {
println!("Dropped! {}", self.0);
}
}
fn get_drop(str: &'static str) -> Option<LoudDrop> {
Some(LoudDrop(str))
}
fn main() {
println!("1");
if get_drop("first").is_some() && get_drop("1.5").is_some() && let None = get_drop("last") {
println!("2");
} else {
println!("2");
}
println!("3");
}
This prints
1
Dropped! 1.5
Dropped! last
2
Dropped! first
3
According to RFC 2497, it should desugar to this: playground
fn main() {
println!("1");
'FRESH_LABEL: {
if get_drop("first").is_some() {
if get_drop("1.5").is_some() {
if let None = get_drop("last") {
break 'FRESH_LABEL { println!("2") }
}
}
}
{ println!("2") }
}
println!("3");
}
But this prints
1
Dropped! first
Dropped! 1.5
Dropped! last
2
3
Meta
Wrong on the current beta
1.64.0-beta.1
(2022-08-09 56714e5332f5f21c39d7)