From 36df98336e38f808e1b9b6d21285544449294130 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 14 May 2024 14:03:33 +0200 Subject: [PATCH 1/2] Add diagram back to RFC 3606. --- text/3606-temporary-lifetimes-in-tail-expressions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/text/3606-temporary-lifetimes-in-tail-expressions.md b/text/3606-temporary-lifetimes-in-tail-expressions.md index 5cef3ca91aa..9a26fc956f4 100644 --- a/text/3606-temporary-lifetimes-in-tail-expressions.md +++ b/text/3606-temporary-lifetimes-in-tail-expressions.md @@ -9,6 +9,12 @@ In the next edition, drop temporaries in tail expressions *before* dropping locals, rather than after. +![A diagram showing a function with one let statement "let x = g();" and a tail expression "temp().h()" +and a visualisation of how long x and temp live before and after this change. +Before: x is created first, then temp is created, then x is dropped, then temp is dropped. +After: x is created first, then temp is created, then temp is dropped, then x is dropped. +](https://github.com/rust-lang/rfcs/assets/783247/07adb0c3-af0a-4761-a696-9bddd0b75c62) + # Motivation Temporaries in the tail expression in a block live longer than the block itself, From db5aeba6a32a47a6a8c3fa859d4af091b8e495ad Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 14 May 2024 17:23:22 +0200 Subject: [PATCH 2/2] Put diagram svg in this repository. --- text/3606-temporary-lifetimes-in-tail-expressions.md | 2 +- text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg diff --git a/text/3606-temporary-lifetimes-in-tail-expressions.md b/text/3606-temporary-lifetimes-in-tail-expressions.md index 9a26fc956f4..1fc5a725d42 100644 --- a/text/3606-temporary-lifetimes-in-tail-expressions.md +++ b/text/3606-temporary-lifetimes-in-tail-expressions.md @@ -13,7 +13,7 @@ In the next edition, drop temporaries in tail expressions *before* dropping loca and a visualisation of how long x and temp live before and after this change. Before: x is created first, then temp is created, then x is dropped, then temp is dropped. After: x is created first, then temp is created, then temp is dropped, then x is dropped. -](https://github.com/rust-lang/rfcs/assets/783247/07adb0c3-af0a-4761-a696-9bddd0b75c62) +](3606-temporary-lifetimes-in-tail-expressions/diagram.svg) # Motivation diff --git a/text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg b/text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg new file mode 100644 index 00000000000..33d72faad94 --- /dev/null +++ b/text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg @@ -0,0 +1,4 @@ + + + +
let x
temp()
drop
drop
let x
temp()
drop
drop
before
after
fn f() {
    let x = g();

    temp().h()
}
\ No newline at end of file