diff --git a/src/test/ui/let-else/let-else-temporary-lifetime.rs b/src/test/ui/let-else/let-else-temporary-lifetime.rs index 28c69ba1ce6..064f28b4d94 100644 --- a/src/test/ui/let-else/let-else-temporary-lifetime.rs +++ b/src/test/ui/let-else/let-else-temporary-lifetime.rs @@ -1,6 +1,7 @@ // run-pass #![feature(let_else)] +use std::fmt::Display; use std::rc::Rc; use std::sync::atomic::{AtomicU8, Ordering}; @@ -18,12 +19,22 @@ impl Drop for Droppy { } } +fn foo<'a>(x: &'a str) -> Result { + Ok(x) +} + fn main() { assert_eq!(TRACKER.load(Ordering::Acquire), 0); let 0 = Droppy::default().inner else { return }; assert_eq!(TRACKER.load(Ordering::Acquire), 1); println!("Should have dropped 👆"); + { + let x = String::from("Hey"); + + let Ok(s) = foo(&x) else { panic!() }; + assert_eq!(s.to_string(), x); + } { // test let-else drops temps after statement let rc = Rc::new(0);