Skip to content

Commit

Permalink
include a demo that more programs can be compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Jul 22, 2022
1 parent baf9a7c commit 60be2de
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/let-else/let-else-temporary-lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 60be2de

Please sign in to comment.