Skip to content

Commit baf9a7c

Browse files
provide a test for rust-lang#93951
1 parent 9b56640 commit baf9a7c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/ui/let-else/let-else-temporary-lifetime.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-pass
22
#![feature(let_else)]
33

4+
use std::fmt::Display;
45
use std::rc::Rc;
56
use std::sync::atomic::{AtomicU8, Ordering};
67

@@ -18,12 +19,22 @@ impl Drop for Droppy {
1819
}
1920
}
2021

22+
fn foo<'a>(x: &'a str) -> Result<impl Display + 'a, ()> {
23+
Ok(x)
24+
}
25+
2126
fn main() {
2227
assert_eq!(TRACKER.load(Ordering::Acquire), 0);
2328
let 0 = Droppy::default().inner else { return };
2429
assert_eq!(TRACKER.load(Ordering::Acquire), 1);
2530
println!("Should have dropped 👆");
2631

32+
{
33+
let x = String::from("Hey");
34+
35+
let Ok(s) = foo(&x) else { panic!() };
36+
assert_eq!(s.to_string(), x);
37+
}
2738
{
2839
// test let-else drops temps after statement
2940
let rc = Rc::new(0);

0 commit comments

Comments
 (0)