add test for earlier drop despite extend lifetime

This commit is contained in:
Ding Xiang Fei 2022-07-31 20:31:53 +08:00
parent 02443552c5
commit e26285603c
No known key found for this signature in database
GPG Key ID: 3CD748647EEF6359

View File

@ -74,6 +74,17 @@ fn main() {
};
}
}
{
fn must_pass() {
let rc = Rc::new(());
let &None = &Some(Rc::clone(&rc)) else {
Rc::try_unwrap(rc).unwrap();
return;
};
unreachable!();
}
must_pass();
}
{
// test let-else drops temps before else block
// NOTE: this test has to be the last block in the `main`