mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
provide a test for #93951
This commit is contained in:
parent
9b56640106
commit
baf9a7cb57
@ -1,6 +1,7 @@
|
|||||||
// run-pass
|
// run-pass
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::{AtomicU8, Ordering};
|
use std::sync::atomic::{AtomicU8, Ordering};
|
||||||
|
|
||||||
@ -18,12 +19,22 @@ impl Drop for Droppy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn foo<'a>(x: &'a str) -> Result<impl Display + 'a, ()> {
|
||||||
|
Ok(x)
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(TRACKER.load(Ordering::Acquire), 0);
|
assert_eq!(TRACKER.load(Ordering::Acquire), 0);
|
||||||
let 0 = Droppy::default().inner else { return };
|
let 0 = Droppy::default().inner else { return };
|
||||||
assert_eq!(TRACKER.load(Ordering::Acquire), 1);
|
assert_eq!(TRACKER.load(Ordering::Acquire), 1);
|
||||||
println!("Should have dropped 👆");
|
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
|
// test let-else drops temps after statement
|
||||||
let rc = Rc::new(0);
|
let rc = Rc::new(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user