about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorTaylor Yu <tlyu@mit.edu>2021-06-19 15:28:32 -0500
committerTaylor Yu <tlyu@mit.edu>2021-07-04 10:04:37 -0500
commit92197a551f8210d9f7d8658f60d738e4ea3c7dd6 (patch)
tree12429d62f36c3f8bda70b5cb21078397c7e70293 /compiler/rustc_error_codes/src
parente062e5d34ee80e0d5da403e8c5609f29e6a7dbcb (diff)
downloadrust-92197a551f8210d9f7d8658f60d738e4ea3c7dd6.tar.gz
rust-92197a551f8210d9f7d8658f60d738e4ea3c7dd6.zip
E0716: clarify that equivalent code example is erroneous
In E0716, there is a code block that is equivalent to the erroneous
code example. Especially when viewed with `rustc --explain`, it's
not obvious that it is also erroneous, and some users have been
confused when they try to change their code to match the erroneous
equivalent.
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0716.md6
1 files changed, 4 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 c6d0337ddda..c3546cd744f 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0716.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0716.md
@@ -14,14 +14,16 @@ Here, the expression `&foo()` is borrowing the expression `foo()`. As `foo()` is
 a call to a function, and not the name of a variable, this creates a
 **temporary** -- that temporary stores the return value from `foo()` so that it
 can be borrowed. You could imagine that `let p = bar(&foo());` is equivalent to
-this:
+the following, which uses an explicit temporary variable.
+
+Erroneous code example:
 
 ```compile_fail,E0597
 # fn foo() -> i32 { 22 }
 # fn bar(x: &i32) -> &i32 { x }
 let p = {
   let tmp = foo(); // the temporary
-  bar(&tmp)
+  bar(&tmp) // error: `tmp` does not live long enough
 }; // <-- tmp is freed as we exit this block
 let q = p;
 ```