From 71a697327bd64bdebcdf81b10c3dd03dfe33cb68 Mon Sep 17 00:00:00 2001 From: carschandler <92899389+carschandler@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:23:05 -0600 Subject: [PATCH 1/2] Update E0716.md for clarity When reading through this, I got slightly hung up thinking the `let` it was referring to was the `let tmp` on line 25, which was confusing considering the comment states that the temporary is freed at the end of the block. I think adding this clarification could potentially help some beginners like myself without being overly verbose. --- compiler/rustc_error_codes/src/error_codes/E0716.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0716.md b/compiler/rustc_error_codes/src/error_codes/E0716.md index c3546cd744f7b..b50c8b8e7ca23 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0716.md +++ b/compiler/rustc_error_codes/src/error_codes/E0716.md @@ -30,8 +30,9 @@ let q = p; Whenever a temporary is created, it is automatically dropped (freed) according to fixed rules. Ordinarily, the temporary is dropped at the end of the enclosing -statement -- in this case, after the `let`. This is illustrated in the example -above by showing that `tmp` would be freed as we exit the block. +statement -- in this case, after the outer `let` that assigns to `p`. This is +illustrated in the example above by showing that `tmp` would be freed as we exit +the block. To fix this problem, you need to create a local variable to store the value in rather than relying on a temporary. For example, you might change the original From 50ff36239a424c855a5faeac45ac269e1c3f54d8 Mon Sep 17 00:00:00 2001 From: carschandler <92899389+carschandler@users.noreply.github.com> Date: Fri, 1 Mar 2024 17:31:02 -0600 Subject: [PATCH 2/2] Update E0716.md Clearer wording --- compiler/rustc_error_codes/src/error_codes/E0716.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0716.md b/compiler/rustc_error_codes/src/error_codes/E0716.md index b50c8b8e7ca23..be60716a26426 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0716.md +++ b/compiler/rustc_error_codes/src/error_codes/E0716.md @@ -30,9 +30,8 @@ let q = p; Whenever a temporary is created, it is automatically dropped (freed) according to fixed rules. Ordinarily, the temporary is dropped at the end of the enclosing -statement -- in this case, after the outer `let` that assigns to `p`. This is -illustrated in the example above by showing that `tmp` would be freed as we exit -the block. +statement -- in this case, after the `let p`. This is illustrated in the example +above by showing that `tmp` would be freed as we exit the block. To fix this problem, you need to create a local variable to store the value in rather than relying on a temporary. For example, you might change the original