include a demo that more programs can be compiled

This commit is contained in:
Ding Xiang Fei 2022-07-22 18:13:17 +08:00
parent baf9a7cb57
commit 60be2de8b7
No known key found for this signature in database
GPG key ID: 3CD748647EEF6359

View file

@ -29,6 +29,21 @@ fn main() {
assert_eq!(TRACKER.load(Ordering::Acquire), 1);
println!("Should have dropped 👆");
{
// cf. https://github.com/rust-lang/rust/pull/99518#issuecomment-1191520030
struct Foo<'a>(&'a mut u32);
impl<'a> Drop for Foo<'a> {
fn drop(&mut self) {
*self.0 = 0;
}
}
let mut foo = 0;
let Foo(0) = Foo(&mut foo) else {
*&mut foo = 1;
todo!()
};
}
{
let x = String::from("Hey");
@ -61,6 +76,8 @@ fn main() {
}
{
// test let-else drops temps before else block
// NOTE: this test has to be the last block in the `main`
// body.
let rc = Rc::new(0);
let 1 = *rc.clone() else {
Rc::try_unwrap(rc).unwrap();