From e26285603ca8b83b9d06e56f74e10e3d410553ff Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Sun, 31 Jul 2022 20:31:53 +0800 Subject: [PATCH] add test for earlier drop despite extend lifetime --- src/test/ui/let-else/let-else-temporary-lifetime.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/ui/let-else/let-else-temporary-lifetime.rs b/src/test/ui/let-else/let-else-temporary-lifetime.rs index 9c86901b97f03..07fcc16e7bbda 100644 --- a/src/test/ui/let-else/let-else-temporary-lifetime.rs +++ b/src/test/ui/let-else/let-else-temporary-lifetime.rs @@ -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`