From 6c5013c53f026963b3fc016ceadfb941cf6d34bf Mon Sep 17 00:00:00 2001 From: dianne Date: Tue, 26 Aug 2025 09:09:25 -0700 Subject: [PATCH] Clean up and properly test temporary lifetime extension - Removes an unused trait and impl from the successful tests. - Adds uses following all tests so they test lifetime extension. --- src/destructors.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/destructors.md b/src/destructors.md index 36e0fe1ed0..24ed38e2f2 100644 --- a/src/destructors.md +++ b/src/destructors.md @@ -448,15 +448,18 @@ Here are some examples where expressions have extended temporary scopes: ```rust # fn temp() {} -# trait Use { fn use_temp(&self) -> &Self { self } } -# impl Use for () {} // The temporary that stores the result of `temp()` lives in the same scope // as x in these cases. let x = &temp(); +# x; let x = &temp() as &dyn Send; +# x; let x = (&*&temp(),); +# x; let x = { [Some(&temp()) ] }; +# x; let ref x = temp(); +# x; let ref x = *&temp(); # x; ``` @@ -471,6 +474,7 @@ Here are some examples where expressions don't have extended temporary scopes: // end of the let statement in these cases. let x = std::convert::identity(&temp()); // ERROR +# x; let x = (&temp()).use_temp(); // ERROR # x; ```