]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_error_codes/src/error_codes/E0716.md
New upstream version 1.55.0+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0716.md
index c6d0337ddda56d0c10efa53e415cb69d9eb5b35a..c3546cd744f7b6be9527aa18cfc3eb1d0805aa74 100644 (file)
@@ -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;
 ```