We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9b56640 commit baf9a7cCopy full SHA for baf9a7c
src/test/ui/let-else/let-else-temporary-lifetime.rs
@@ -1,6 +1,7 @@
1
// run-pass
2
#![feature(let_else)]
3
4
+use std::fmt::Display;
5
use std::rc::Rc;
6
use std::sync::atomic::{AtomicU8, Ordering};
7
@@ -18,12 +19,22 @@ impl Drop for Droppy {
18
19
}
20
21
22
+fn foo<'a>(x: &'a str) -> Result<impl Display + 'a, ()> {
23
+ Ok(x)
24
+}
25
+
26
fn main() {
27
assert_eq!(TRACKER.load(Ordering::Acquire), 0);
28
let 0 = Droppy::default().inner else { return };
29
assert_eq!(TRACKER.load(Ordering::Acquire), 1);
30
println!("Should have dropped 👆");
31
32
+ {
33
+ let x = String::from("Hey");
34
35
+ let Ok(s) = foo(&x) else { panic!() };
36
+ assert_eq!(s.to_string(), x);
37
+ }
38
{
39
// test let-else drops temps after statement
40
let rc = Rc::new(0);
0 commit comments