about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikhail Modin <mikhailm1@gmail.com>2018-09-23 16:30:46 +0100
committerMikhail Modin <mikhailm1@gmail.com>2018-09-25 15:23:56 +0100
commit5fc0b743d752f57d39cbd7ff10450211affe79a0 (patch)
treee1ee7b6b3938d98f71dfc7bda762a1dba5785371
parentae366637fedf6f34185e54fc7b2d725b1a458ff6 (diff)
downloadrust-5fc0b743d752f57d39cbd7ff10450211affe79a0.tar.gz
rust-5fc0b743d752f57d39cbd7ff10450211affe79a0.zip
add "temporary value dropped while borrowed" error
Issue #54131
-rw-r--r--src/librustc_mir/borrow_check/error_reporting.rs6
-rw-r--r--src/librustc_mir/diagnostics.rs85
-rw-r--r--src/librustc_mir/util/borrowck_errors.rs16
-rw-r--r--src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr18
-rw-r--r--src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr8
-rw-r--r--src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr8
-rw-r--r--src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr32
-rw-r--r--src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr43
-rw-r--r--src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr24
-rw-r--r--src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr35
-rw-r--r--src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr14
-rw-r--r--src/test/ui/consts/const-eval/union_promotion.nll.stderr16
-rw-r--r--src/test/ui/consts/const-int-conversion.nll.stderr80
-rw-r--r--src/test/ui/consts/const-int-overflowing.nll.stderr35
-rw-r--r--src/test/ui/consts/const-int-rotate.nll.stderr24
-rw-r--r--src/test/ui/consts/const-int-sign.nll.stderr24
-rw-r--r--src/test/ui/consts/const-int-wrapping.nll.stderr57
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr8
-rw-r--r--src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr8
-rw-r--r--src/test/ui/issues/issue-11681.nll.stderr18
-rw-r--r--src/test/ui/issues/issue-17545.nll.stderr8
-rw-r--r--src/test/ui/issues/issue-17718-constants-not-static.nll.stderr13
-rw-r--r--src/test/ui/issues/issue-27592.nll.stderr14
-rw-r--r--src/test/ui/issues/issue-30438-a.nll.stderr8
-rw-r--r--src/test/ui/issues/issue-30438-b.nll.stderr21
-rw-r--r--src/test/ui/issues/issue-36082.ast.nll.stderr8
-rw-r--r--src/test/ui/issues/issue-36082.mir.stderr8
-rw-r--r--src/test/ui/issues/issue-36082.rs6
-rw-r--r--src/test/ui/issues/issue-44373.nll.stderr13
-rw-r--r--src/test/ui/issues/issue-46472.rs2
-rw-r--r--src/test/ui/issues/issue-46472.stderr9
-rw-r--r--src/test/ui/issues/issue-47184.rs2
-rw-r--r--src/test/ui/issues/issue-47184.stderr8
-rw-r--r--src/test/ui/issues/issue-52049.nll.stderr8
-rw-r--r--src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr8
-rw-r--r--src/test/ui/nll/borrowed-temporary-error.rs2
-rw-r--r--src/test/ui/nll/borrowed-temporary-error.stderr10
-rw-r--r--src/test/ui/nll/borrowed-universal-error.rs2
-rw-r--r--src/test/ui/nll/borrowed-universal-error.stderr10
-rw-r--r--src/test/ui/nll/issue-52534-1.stderr9
-rw-r--r--src/test/ui/nll/return-ref-mut-issue-46557.rs2
-rw-r--r--src/test/ui/nll/return-ref-mut-issue-46557.stderr10
-rw-r--r--src/test/ui/nll/user-annotations/patterns.rs6
-rw-r--r--src/test/ui/nll/user-annotations/patterns.stderr21
-rw-r--r--src/test/ui/regions/regions-creating-enums.nll.stderr14
-rw-r--r--src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr8
-rw-r--r--src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr33
-rw-r--r--src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr14
-rw-r--r--src/test/ui/regions/regions-ret.nll.stderr8
-rw-r--r--src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr13
-rw-r--r--src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr8
-rw-r--r--src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr20
-rw-r--r--src/test/ui/span/issue-15480.nll.stderr8
-rw-r--r--src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr8
-rw-r--r--src/test/ui/span/slice-borrow.nll.stderr8
-rw-r--r--src/test/ui/static/static-drop-scope.nll.stderr60
-rw-r--r--src/test/ui/static/static-reference-to-fn-2.nll.stderr26
-rw-r--r--src/test/ui/static/static-region-bound.nll.stderr14
-rw-r--r--src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr27
59 files changed, 848 insertions, 188 deletions
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs
index b775fc81d4f..f29870623a9 100644
--- a/src/librustc_mir/borrow_check/error_reporting.rs
+++ b/src/librustc_mir/borrow_check/error_reporting.rs
@@ -694,9 +694,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
 
         let tcx = self.infcx.tcx;
         let mut err =
-            tcx.path_does_not_live_long_enough(proper_span, "borrowed value", Origin::Mir);
-        err.span_label(proper_span, "temporary value does not live long enough");
-        err.span_label(drop_span, "temporary value only lives until here");
+            tcx.temporary_value_borrowed_for_too_long(proper_span, Origin::Mir);
+        err.span_label(proper_span, "creates a temporary which is freed while still in use");
+        err.span_label(drop_span, "temporary value is freed at the end of this statement");
 
         let explanation = self.explain_why_borrow_contains_point(context, borrow, None);
         match explanation {
diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs
index 0c31e5c4da8..aac5fc5ed7e 100644
--- a/src/librustc_mir/diagnostics.rs
+++ b/src/librustc_mir/diagnostics.rs
@@ -2261,7 +2261,92 @@ that after `demo` finishes excuting, something else (such as the
 destructor!) could access `s.data` after the end of that shorter
 lifetime, which would again violate the `&mut`-borrow's exclusive
 access.
+"##,
+
+E0714: r##"
+This error indicates that a temporary value is being dropped
+while a borrow is still in active use.
+
+Erroneous code example:
+
+```compile_fail,E0714
+# #![feature(nll)]
+fn foo() -> i32 { 22 }
+fn bar(x: &i32) -> &i32 { x }
+let p = bar(&foo());
+         // ------ creates a temporary
+let q = *p;
+```
+
+Here, the expression `&foo()` is borrowing the expression
+`foo()`. As `foo()` is 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.
+So you might imagine that `let p = bar(&foo())` is equivalent
+to this:
+
+```compile_fail,E0597
+# fn foo() -> i32 { 22 }
+# fn bar(x: &i32) -> &i32 { x }
+let p = {
+  let tmp = foo(); // the temporary
+  bar(&tmp)
+}; // <-- tmp is freed as we exit this block
+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.
+
+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 program to
+the following:
 
+```
+fn foo() -> i32 { 22 }
+fn bar(x: &i32) -> &i32 { x }
+let value = foo(); // dropped at the end of the enclosing block
+let p = bar(&value);
+let q = *p;
+```
+
+By introducing the explicit `let value`, we allocate storage
+that will last until the end of the enclosing block (when `value`
+goes out of scope). When we borrow `&value`, we are borrowing a
+local variable that already exists, and hence no temporary is created.
+
+Temporaries are not always dropped at the end of the enclosing
+statement. In simple cases where the `&` expression is immediately
+stored into a variable, the compiler will automatically extend
+the lifetime of the temporary until the end of the enclosinb
+block. Therefore, an alternative way to fix the original
+program is to write `let tmp = &foo()` and not `let tmp = foo()`:
+
+```
+fn foo() -> i32 { 22 }
+fn bar(x: &i32) -> &i32 { x }
+let value = &foo();
+let p = bar(value);
+let q = *p;
+```
+
+Here, we are still borrowing `foo()`, but as the borrow is assigned
+directly into a variable, the temporary will not be dropped until
+the end of the enclosing block. Similar rules apply when temporaries
+are stored into aggregate structures like a tuple or struct:
+
+```
+// Here, two temporaries are created, but
+// as they are stored directly into `value`,
+// they are not dropped until the end of the
+// enclosing block.
+fn foo() -> i32 { 22 }
+let value = (&foo(), &foo());
+```
 "##,
 
 }
diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs
index 6d5d3ba88f2..c78020a2609 100644
--- a/src/librustc_mir/util/borrowck_errors.rs
+++ b/src/librustc_mir/util/borrowck_errors.rs
@@ -730,6 +730,22 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
 
         self.cancel_if_wrong_origin(err, o)
     }
+
+    fn temporary_value_borrowed_for_too_long(
+        self,
+        span: Span,
+        o: Origin,
+    ) -> DiagnosticBuilder<'cx> {
+        let err = struct_span_err!(
+            self,
+            span,
+            E0714,
+            "temporary value dropped while borrowed{OGN}",
+            OGN = o
+        );
+
+        self.cancel_if_wrong_origin(err, o)
+    }
 }
 
 impl<'cx, 'gcx, 'tcx> BorrowckErrors<'cx> for TyCtxt<'cx, 'gcx, 'tcx> {
diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr
new file mode 100644
index 00000000000..894eb4cc4a2
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr
@@ -0,0 +1,18 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/borrowck-borrow-from-temporary.rs:19:24
+   |
+LL |     let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough
+   |                        ^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     x
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:8...
+  --> $DIR/borrowck-borrow-from-temporary.rs:18:8
+   |
+LL | fn foo<'a>() -> &'a isize {
+   |        ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr
index eee3f9bd5c1..1b5a1f4b29b 100644
--- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:32:20
    |
 LL |     let x = defer(&vec!["Goodbye", "world!"]);
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value only lives until here
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
    |                    |
-   |                    temporary value does not live long enough
+   |                    creates a temporary which is freed while still in use
 LL |     x.x[0];
    |     ------ borrow later used here
    |
@@ -13,4 +13,4 @@ LL |     x.x[0];
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr
index ebf229696d8..9236e9e2288 100644
--- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-borrowed-uniq-rvalue.rs:20:28
    |
 LL |     buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough
-   |                            ^^^^^^^^^^^ - temporary value only lives until here
+   |                            ^^^^^^^^^^^ - temporary value is freed at the end of this statement
    |                            |
-   |                            temporary value does not live long enough
+   |                            creates a temporary which is freed while still in use
 ...
 LL |     buggy_map.insert(43, &*tmp);
    |     --------- borrow later used here
@@ -13,4 +13,4 @@ LL |     buggy_map.insert(43, &*tmp);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr
index 52f1547bce6..a4fc91f208d 100644
--- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr
+++ b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr
@@ -1,57 +1,57 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:21
    |
 LL |     let ref mut x = 1234543; //~ ERROR
-   |                     ^^^^^^^ temporary value does not live long enough
+   |                     ^^^^^^^ creates a temporary which is freed while still in use
 LL |     x
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/promote-ref-mut-in-let-issue-46557.rs:20:25
    |
 LL |     let (ref mut x, ) = (1234543, ); //~ ERROR
-   |                         ^^^^^^^^^^^ temporary value does not live long enough
+   |                         ^^^^^^^^^^^ creates a temporary which is freed while still in use
 LL |     x
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/promote-ref-mut-in-let-issue-46557.rs:25:11
    |
 LL |     match 1234543 {
-   |           ^^^^^^^ temporary value does not live long enough
+   |           ^^^^^^^ creates a temporary which is freed while still in use
 ...
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/promote-ref-mut-in-let-issue-46557.rs:31:11
    |
 LL |     match (123443,) {
-   |           ^^^^^^^^^ temporary value does not live long enough
+   |           ^^^^^^^^^ creates a temporary which is freed while still in use
 ...
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/promote-ref-mut-in-let-issue-46557.rs:37:10
    |
 LL |     &mut 1234543 //~ ERROR
-   |          ^^^^^^^ temporary value does not live long enough
+   |          ^^^^^^^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr
new file mode 100644
index 00000000000..e257fdb31e7
--- /dev/null
+++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr
@@ -0,0 +1,43 @@
+error: `foo` is not yet stable as a const fn
+  --> $DIR/dont_promote_unstable_const_fn.rs:25:25
+   |
+LL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn
+   |                         ^^^^^
+   |
+   = help: in Nightly builds, add `#![feature(foo)]` to the crate attributes to enable
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/dont_promote_unstable_const_fn.rs:28:28
+   |
+LL |     let _: &'static u32 = &foo(); //~ ERROR does not live long enough
+   |                            ^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/dont_promote_unstable_const_fn.rs:32:28
+   |
+LL |     let _: &'static u32 = &meh(); //~ ERROR does not live long enough
+   |                            ^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/dont_promote_unstable_const_fn.rs:33:26
+   |
+LL |     let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     //~^ does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr
new file mode 100644
index 00000000000..6ec07336409
--- /dev/null
+++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr
@@ -0,0 +1,24 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:18:28
+   |
+LL |     let _: &'static u32 = &foo(); //~ ERROR does not live long enough
+   |                            ^^^^^ creates a temporary which is freed while still in use
+LL |     let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:19:29
+   |
+LL |     let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
+   |                             ^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr
new file mode 100644
index 00000000000..acc6104d9e2
--- /dev/null
+++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr
@@ -0,0 +1,35 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/promoted_raw_ptr_ops.rs:14:29
+   |
+LL |     let x: &'static bool = &(42 as *const i32 == 43 as *const i32);
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/promoted_raw_ptr_ops.rs:16:30
+   |
+LL |     let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
+   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/promoted_raw_ptr_ops.rs:17:28
+   |
+LL |     let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr
new file mode 100644
index 00000000000..e11f589b105
--- /dev/null
+++ b/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr
@@ -0,0 +1,14 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/transmute-const-promotion.rs:16:37
+   |
+LL |     let x: &'static u32 = unsafe { &mem::transmute(3.0f32) };
+   |                                     ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     //~^ ERROR value does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-eval/union_promotion.nll.stderr b/src/test/ui/consts/const-eval/union_promotion.nll.stderr
new file mode 100644
index 00000000000..9437cacd773
--- /dev/null
+++ b/src/test/ui/consts/const-eval/union_promotion.nll.stderr
@@ -0,0 +1,16 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/union_promotion.rs:19:29
+   |
+LL |       let x: &'static bool = &unsafe { //~ borrowed value does not live long enough
+   |  _____________________________^
+LL | |         Foo { a: &1 }.b == Foo { a: &2 }.b
+LL | |     };
+   | |_____^ creates a temporary which is freed while still in use
+LL |   }
+   |   - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-int-conversion.nll.stderr b/src/test/ui/consts/const-int-conversion.nll.stderr
new file mode 100644
index 00000000000..922905477f3
--- /dev/null
+++ b/src/test/ui/consts/const-int-conversion.nll.stderr
@@ -0,0 +1,80 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:14:28
+   |
+LL |     let x: &'static i32 = &(5_i32.reverse_bits());
+   |                            ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:16:28
+   |
+LL |     let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:18:28
+   |
+LL |     let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:20:28
+   |
+LL |     let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:22:29
+   |
+LL |     let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:24:29
+   |
+LL |     let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-conversion.rs:26:29
+   |
+LL |     let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |         //~^ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-int-overflowing.nll.stderr b/src/test/ui/consts/const-int-overflowing.nll.stderr
new file mode 100644
index 00000000000..fd420658c7a
--- /dev/null
+++ b/src/test/ui/consts/const-int-overflowing.nll.stderr
@@ -0,0 +1,35 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-overflowing.rs:12:36
+   |
+LL |     let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-overflowing.rs:13:36
+   |
+LL |     let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-overflowing.rs:14:36
+   |
+LL |     let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-int-rotate.nll.stderr b/src/test/ui/consts/const-int-rotate.nll.stderr
new file mode 100644
index 00000000000..d66017a289b
--- /dev/null
+++ b/src/test/ui/consts/const-int-rotate.nll.stderr
@@ -0,0 +1,24 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-rotate.rs:12:28
+   |
+LL |     let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-rotate.rs:13:28
+   |
+LL |     let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-int-sign.nll.stderr b/src/test/ui/consts/const-int-sign.nll.stderr
new file mode 100644
index 00000000000..62a2b111ed9
--- /dev/null
+++ b/src/test/ui/consts/const-int-sign.nll.stderr
@@ -0,0 +1,24 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-sign.rs:12:29
+   |
+LL |     let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough
+   |                             ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-sign.rs:13:29
+   |
+LL |     let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough
+   |                             ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/const-int-wrapping.nll.stderr b/src/test/ui/consts/const-int-wrapping.nll.stderr
new file mode 100644
index 00000000000..4c6c98188dc
--- /dev/null
+++ b/src/test/ui/consts/const-int-wrapping.nll.stderr
@@ -0,0 +1,57 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-wrapping.rs:12:28
+   |
+LL |     let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-wrapping.rs:13:28
+   |
+LL |     let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-wrapping.rs:14:28
+   |
+LL |     let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-wrapping.rs:15:28
+   |
+LL |     let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |     let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/const-int-wrapping.rs:16:28
+   |
+LL |     let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr
index 5803b5e355a..d79fd657119 100644
--- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr
+++ b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr
@@ -190,13 +190,13 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
 LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/min_const_fn.rs:144:64
    |
 LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
-   |                                                                ^^ - temporary value only lives until here
+   |                                                                ^^ - temporary value is freed at the end of this statement
    |                                                                |
-   |                                                                temporary value does not live long enough
+   |                                                                creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
@@ -220,5 +220,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
 
 error: aborting due to 36 previous errors
 
-Some errors occurred: E0493, E0597.
+Some errors occurred: E0493, E0714.
 For more information about an error, try `rustc --explain E0493`.
diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr
index cfcc7990fb3..8d8fe7cfbeb 100644
--- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr
+++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr
@@ -10,16 +10,16 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
 LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
    |                                                                  ^^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/min_const_fn_dyn.rs:24:67
    |
 LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
-   |                                                                   ^    - temporary value only lives until here
+   |                                                                   ^    - temporary value is freed at the end of this statement
    |                                                                   |
-   |                                                                   temporary value does not live long enough
+   |                                                                   creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-11681.nll.stderr b/src/test/ui/issues/issue-11681.nll.stderr
new file mode 100644
index 00000000000..8ded4f6e768
--- /dev/null
+++ b/src/test/ui/issues/issue-11681.nll.stderr
@@ -0,0 +1,18 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/issue-11681.rs:22:20
+   |
+LL |   let testValue = &Test; //~ ERROR borrowed value does not live long enough
+   |                    ^^^^ creates a temporary which is freed while still in use
+LL |   return testValue;
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:15...
+  --> $DIR/issue-11681.rs:21:15
+   |
+LL | fn createTest<'a>() -> &'a Test {
+   |               ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-17545.nll.stderr b/src/test/ui/issues/issue-17545.nll.stderr
index 50a4b3f7f3e..3f9fa694c34 100644
--- a/src/test/ui/issues/issue-17545.nll.stderr
+++ b/src/test/ui/issues/issue-17545.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-17545.rs:17:10
    |
 LL |         &id(()), //~ ERROR borrowed value does not live long enough
-   |          ^^^^^^ temporary value does not live long enough
+   |          ^^^^^^ creates a temporary which is freed while still in use
 LL |     ));
-   |       - temporary value only lives until here
+   |       - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:12...
   --> $DIR/issue-17545.rs:15:12
@@ -14,4 +14,4 @@ LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr b/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr
new file mode 100644
index 00000000000..c0795acbbb9
--- /dev/null
+++ b/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr
@@ -0,0 +1,13 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/issue-17718-constants-not-static.rs:15:31
+   |
+LL | fn foo() -> &'static usize { &id(FOO) }
+   |                               ^^^^^^^ - temporary value is freed at the end of this statement
+   |                               |
+   |                               creates a temporary which is freed while still in use
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-27592.nll.stderr b/src/test/ui/issues/issue-27592.nll.stderr
index 36a15e79ac8..a41b3f82018 100644
--- a/src/test/ui/issues/issue-27592.nll.stderr
+++ b/src/test/ui/issues/issue-27592.nll.stderr
@@ -1,19 +1,19 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-27592.rs:26:27
    |
 LL |     write(|| format_args!("{}", String::from("Hello world")));
-   |                           ^^^^                             - temporary value only lives until here
+   |                           ^^^^                             - temporary value is freed at the end of this statement
    |                           |
-   |                           temporary value does not live long enough
+   |                           creates a temporary which is freed while still in use
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-27592.rs:26:33
    |
 LL |     write(|| format_args!("{}", String::from("Hello world")));
-   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                                 |
-   |                                 temporary value does not live long enough
+   |                                 creates a temporary which is freed while still in use
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-30438-a.nll.stderr b/src/test/ui/issues/issue-30438-a.nll.stderr
index 2d27cd55e01..9acaaaa2747 100644
--- a/src/test/ui/issues/issue-30438-a.nll.stderr
+++ b/src/test/ui/issues/issue-30438-a.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-30438-a.rs:22:17
    |
 LL |         return &Test { s: &self.s};
-   |                 ^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                 ^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                 |
-   |                 temporary value does not live long enough
+   |                 creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 21:5...
   --> $DIR/issue-30438-a.rs:21:5
@@ -17,4 +17,4 @@ LL | |     }
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-30438-b.nll.stderr b/src/test/ui/issues/issue-30438-b.nll.stderr
new file mode 100644
index 00000000000..02344c50a38
--- /dev/null
+++ b/src/test/ui/issues/issue-30438-b.nll.stderr
@@ -0,0 +1,21 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/issue-30438-b.rs:23:10
+   |
+LL |         &Test { s: &self.s}
+   |          ^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+LL |         //~^ ERROR: borrowed value does not live long enough
+LL |     }
+   |     - temporary value is freed at the end of this statement
+   |
+note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 22:5...
+  --> $DIR/issue-30438-b.rs:22:5
+   |
+LL | /     fn index(&self, _: usize) -> &Self::Output {
+LL | |         &Test { s: &self.s}
+LL | |         //~^ ERROR: borrowed value does not live long enough
+LL | |     }
+   | |_____^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-36082.ast.nll.stderr b/src/test/ui/issues/issue-36082.ast.nll.stderr
index e02f21f6e12..4a481da6522 100644
--- a/src/test/ui/issues/issue-36082.ast.nll.stderr
+++ b/src/test/ui/issues/issue-36082.ast.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-36082.rs:23:19
    |
 LL |     let val: &_ = x.borrow().0;
-   |                   ^^^^^^^^^^  - temporary value only lives until here
+   |                   ^^^^^^^^^^  - temporary value is freed at the end of this statement
    |                   |
-   |                   temporary value does not live long enough
+   |                   creates a temporary which is freed while still in use
 ...
 LL |     println!("{}", val);
    |                    --- borrow later used here
@@ -13,4 +13,4 @@ LL |     println!("{}", val);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-36082.mir.stderr b/src/test/ui/issues/issue-36082.mir.stderr
index e02f21f6e12..4a481da6522 100644
--- a/src/test/ui/issues/issue-36082.mir.stderr
+++ b/src/test/ui/issues/issue-36082.mir.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-36082.rs:23:19
    |
 LL |     let val: &_ = x.borrow().0;
-   |                   ^^^^^^^^^^  - temporary value only lives until here
+   |                   ^^^^^^^^^^  - temporary value is freed at the end of this statement
    |                   |
-   |                   temporary value does not live long enough
+   |                   creates a temporary which is freed while still in use
 ...
 LL |     println!("{}", val);
    |                    --- borrow later used here
@@ -13,4 +13,4 @@ LL |     println!("{}", val);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-36082.rs b/src/test/ui/issues/issue-36082.rs
index 579ec4d923b..018d5bf0918 100644
--- a/src/test/ui/issues/issue-36082.rs
+++ b/src/test/ui/issues/issue-36082.rs
@@ -25,9 +25,9 @@ fn main() {
     //[ast]~| NOTE temporary value dropped here while still borrowed
     //[ast]~| NOTE temporary value does not live long enough
     //[ast]~| NOTE consider using a `let` binding to increase its lifetime
-    //[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
-    //[mir]~| NOTE temporary value does not live long enough
-    //[mir]~| NOTE temporary value only lives until here
+    //[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0714]
+    //[mir]~| NOTE temporary value is freed at the end of this statement
+    //[mir]~| NOTE creates a temporary which is freed while still in use
     //[mir]~| NOTE consider using a `let` binding to create a longer lived value
     println!("{}", val);
     //[mir]~^ borrow later used here
diff --git a/src/test/ui/issues/issue-44373.nll.stderr b/src/test/ui/issues/issue-44373.nll.stderr
new file mode 100644
index 00000000000..9a6c59aaa20
--- /dev/null
+++ b/src/test/ui/issues/issue-44373.nll.stderr
@@ -0,0 +1,13 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/issue-44373.rs:15:42
+   |
+LL |     let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough
+   |                                          ^^^^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-46472.rs b/src/test/ui/issues/issue-46472.rs
index 02c4dd7cb21..79e805c5356 100644
--- a/src/test/ui/issues/issue-46472.rs
+++ b/src/test/ui/issues/issue-46472.rs
@@ -13,7 +13,7 @@
 fn bar<'a>() -> &'a mut u32 {
     &mut 4
     //~^ ERROR borrowed value does not live long enough (Ast) [E0597]
-    //~| ERROR borrowed value does not live long enough (Mir) [E0597]
+    //~| ERROR temporary value dropped while borrowed (Mir) [E0714]
 }
 
 fn main() { }
diff --git a/src/test/ui/issues/issue-46472.stderr b/src/test/ui/issues/issue-46472.stderr
index 9e5acf56d26..39c4e091fd2 100644
--- a/src/test/ui/issues/issue-46472.stderr
+++ b/src/test/ui/issues/issue-46472.stderr
@@ -13,14 +13,14 @@ note: borrowed value must be valid for the lifetime 'a as defined on the functio
 LL | fn bar<'a>() -> &'a mut u32 {
    |        ^^
 
-error[E0597]: borrowed value does not live long enough (Mir)
+error[E0714]: temporary value dropped while borrowed (Mir)
   --> $DIR/issue-46472.rs:14:10
    |
 LL |     &mut 4
-   |          ^ temporary value does not live long enough
+   |          ^ creates a temporary which is freed while still in use
 ...
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8...
   --> $DIR/issue-46472.rs:13:8
@@ -30,4 +30,5 @@ LL | fn bar<'a>() -> &'a mut u32 {
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+Some errors occurred: E0597, E0714.
+For more information about an error, try `rustc --explain E0597`.
diff --git a/src/test/ui/issues/issue-47184.rs b/src/test/ui/issues/issue-47184.rs
index 0831b7e0af8..fbf67a3b4fc 100644
--- a/src/test/ui/issues/issue-47184.rs
+++ b/src/test/ui/issues/issue-47184.rs
@@ -12,5 +12,5 @@
 
 fn main() {
     let _vec: Vec<&'static String> = vec![&String::new()];
-    //~^ ERROR borrowed value does not live long enough [E0597]
+    //~^ ERROR temporary value dropped while borrowed [E0714]
 }
diff --git a/src/test/ui/issues/issue-47184.stderr b/src/test/ui/issues/issue-47184.stderr
index 32a9783e9c2..1a4b7ae16bf 100644
--- a/src/test/ui/issues/issue-47184.stderr
+++ b/src/test/ui/issues/issue-47184.stderr
@@ -1,13 +1,13 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-47184.rs:14:44
    |
 LL |     let _vec: Vec<&'static String> = vec![&String::new()];
-   |                                            ^^^^^^^^^^^^^ - temporary value only lives until here
+   |                                            ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
    |                                            |
-   |                                            temporary value does not live long enough
+   |                                            creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/issues/issue-52049.nll.stderr b/src/test/ui/issues/issue-52049.nll.stderr
index 6f71f167611..ad4cd48c9de 100644
--- a/src/test/ui/issues/issue-52049.nll.stderr
+++ b/src/test/ui/issues/issue-52049.nll.stderr
@@ -1,13 +1,13 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-52049.rs:16:10
    |
 LL |     foo(&unpromotable(5u32));
-   |          ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+   |          ^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr
index a8a1b33c925..0747405cf14 100644
--- a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr
+++ b/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-let-suggestion.rs:12:17
    |
 LL |     let mut x = vec![1].iter();
-   |                 ^^^^^^^       - temporary value only lives until here
+   |                 ^^^^^^^       - temporary value is freed at the end of this statement
    |                 |
-   |                 temporary value does not live long enough
+   |                 creates a temporary which is freed while still in use
 LL |     //~^ ERROR borrowed value does not live long enough
 LL |     x.use_mut();
    |     - borrow later used here
@@ -14,4 +14,4 @@ LL |     x.use_mut();
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/nll/borrowed-temporary-error.rs b/src/test/ui/nll/borrowed-temporary-error.rs
index 7aad7205a52..d0b53359cd0 100644
--- a/src/test/ui/nll/borrowed-temporary-error.rs
+++ b/src/test/ui/nll/borrowed-temporary-error.rs
@@ -18,7 +18,7 @@ fn main() {
     let x = gimme({
         let v = 22;
         &(v,)
-        //~^ ERROR borrowed value does not live long enough [E0597]
+        //~^ ERROR temporary value dropped while borrowed [E0714]
     });
     println!("{:?}", x);
 }
diff --git a/src/test/ui/nll/borrowed-temporary-error.stderr b/src/test/ui/nll/borrowed-temporary-error.stderr
index 8b69c57d376..a929914d8df 100644
--- a/src/test/ui/nll/borrowed-temporary-error.stderr
+++ b/src/test/ui/nll/borrowed-temporary-error.stderr
@@ -1,11 +1,11 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowed-temporary-error.rs:20:10
    |
 LL |         &(v,)
-   |          ^^^^ temporary value does not live long enough
-LL |         //~^ ERROR borrowed value does not live long enough [E0597]
+   |          ^^^^ creates a temporary which is freed while still in use
+LL |         //~^ ERROR temporary value dropped while borrowed [E0714]
 LL |     });
-   |       - temporary value only lives until here
+   |       - temporary value is freed at the end of this statement
 LL |     println!("{:?}", x);
    |                      - borrow later used here
    |
@@ -13,4 +13,4 @@ LL |     println!("{:?}", x);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/nll/borrowed-universal-error.rs b/src/test/ui/nll/borrowed-universal-error.rs
index 9482b9b1400..5ea91d3618a 100644
--- a/src/test/ui/nll/borrowed-universal-error.rs
+++ b/src/test/ui/nll/borrowed-universal-error.rs
@@ -18,7 +18,7 @@ fn gimme(x: &(u32,)) -> &u32 {
 fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
     let v = 22;
     gimme(&(v,))
-    //~^ ERROR borrowed value does not live long enough [E0597]
+    //~^ ERROR temporary value dropped while borrowed [E0714]
 }
 
 fn main() {}
diff --git a/src/test/ui/nll/borrowed-universal-error.stderr b/src/test/ui/nll/borrowed-universal-error.stderr
index da287980e8c..a65a396d2ab 100644
--- a/src/test/ui/nll/borrowed-universal-error.stderr
+++ b/src/test/ui/nll/borrowed-universal-error.stderr
@@ -1,11 +1,11 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowed-universal-error.rs:20:12
    |
 LL |     gimme(&(v,))
-   |            ^^^^ temporary value does not live long enough
-LL |     //~^ ERROR borrowed value does not live long enough [E0597]
+   |            ^^^^ creates a temporary which is freed while still in use
+LL |     //~^ ERROR temporary value dropped while borrowed [E0714]
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:8...
   --> $DIR/borrowed-universal-error.rs:18:8
@@ -15,4 +15,4 @@ LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/nll/issue-52534-1.stderr b/src/test/ui/nll/issue-52534-1.stderr
index e2f8134e3be..9bb32c3ed3d 100644
--- a/src/test/ui/nll/issue-52534-1.stderr
+++ b/src/test/ui/nll/issue-52534-1.stderr
@@ -52,13 +52,13 @@ LL | }
    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-52534-1.rs:30:6
    |
 LL |     &&x
-   |      ^^ temporary value does not live long enough
+   |      ^^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 28:1...
   --> $DIR/issue-52534-1.rs:28:1
@@ -137,4 +137,5 @@ LL | }
 
 error: aborting due to 8 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+Some errors occurred: E0597, E0714.
+For more information about an error, try `rustc --explain E0597`.
diff --git a/src/test/ui/nll/return-ref-mut-issue-46557.rs b/src/test/ui/nll/return-ref-mut-issue-46557.rs
index 79150f340ca..82222530335 100644
--- a/src/test/ui/nll/return-ref-mut-issue-46557.rs
+++ b/src/test/ui/nll/return-ref-mut-issue-46557.rs
@@ -14,7 +14,7 @@
 #![allow(dead_code)]
 
 fn gimme_static_mut() -> &'static mut u32 {
-    let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
+    let ref mut x = 1234543; //~ ERROR temporary value dropped while borrowed [E0714]
     x
 }
 
diff --git a/src/test/ui/nll/return-ref-mut-issue-46557.stderr b/src/test/ui/nll/return-ref-mut-issue-46557.stderr
index f441085f242..1e8224c8ddb 100644
--- a/src/test/ui/nll/return-ref-mut-issue-46557.stderr
+++ b/src/test/ui/nll/return-ref-mut-issue-46557.stderr
@@ -1,14 +1,14 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/return-ref-mut-issue-46557.rs:17:21
    |
-LL |     let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
-   |                     ^^^^^^^ temporary value does not live long enough
+LL |     let ref mut x = 1234543; //~ ERROR temporary value dropped while borrowed [E0714]
+   |                     ^^^^^^^ creates a temporary which is freed while still in use
 LL |     x
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/nll/user-annotations/patterns.rs b/src/test/ui/nll/user-annotations/patterns.rs
index 53d97360c86..971a7377024 100644
--- a/src/test/ui/nll/user-annotations/patterns.rs
+++ b/src/test/ui/nll/user-annotations/patterns.rs
@@ -51,13 +51,13 @@ fn underscore_with_initializer() {
     let _: &'static u32 = &x; //~ ERROR
 
     let _: Vec<&'static String> = vec![&String::new()];
-    //~^ ERROR borrowed value does not live long enough [E0597]
+    //~^ ERROR temporary value dropped while borrowed [E0714]
 
     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
-    //~^ ERROR borrowed value does not live long enough [E0597]
+    //~^ ERROR temporary value dropped while borrowed [E0714]
 
     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
-    //~^ ERROR borrowed value does not live long enough [E0597]
+    //~^ ERROR temporary value dropped while borrowed [E0714]
 }
 
 fn pair_underscores_with_initializer() {
diff --git a/src/test/ui/nll/user-annotations/patterns.stderr b/src/test/ui/nll/user-annotations/patterns.stderr
index f359608462d..0e3109413bd 100644
--- a/src/test/ui/nll/user-annotations/patterns.stderr
+++ b/src/test/ui/nll/user-annotations/patterns.stderr
@@ -40,33 +40,33 @@ LL | }
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/patterns.rs:53:41
    |
 LL |     let _: Vec<&'static String> = vec![&String::new()];
-   |                                         ^^^^^^^^^^^^^ - temporary value only lives until here
+   |                                         ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
    |                                         |
-   |                                         temporary value does not live long enough
+   |                                         creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/patterns.rs:56:52
    |
 LL |     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
-   |                                                    ^^^^^^^^^^^^^      - temporary value only lives until here
+   |                                                    ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
    |                                                    |
-   |                                                    temporary value does not live long enough
+   |                                                    creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/patterns.rs:59:53
    |
 LL |     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
-   |                                                     ^^^^^^^^^^^^^      - temporary value only lives until here
+   |                                                     ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
    |                                                     |
-   |                                                     temporary value does not live long enough
+   |                                                     creates a temporary which is freed while still in use
    |
    = note: borrowed value must be valid for the static lifetime...
 
@@ -140,4 +140,5 @@ LL |     let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR
 
 error: aborting due to 14 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+Some errors occurred: E0597, E0714.
+For more information about an error, try `rustc --explain E0597`.
diff --git a/src/test/ui/regions/regions-creating-enums.nll.stderr b/src/test/ui/regions/regions-creating-enums.nll.stderr
index 58dff9c6c37..df2e3558612 100644
--- a/src/test/ui/regions/regions-creating-enums.nll.stderr
+++ b/src/test/ui/regions/regions-creating-enums.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-creating-enums.rs:33:17
    |
 LL |         return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough
-   |                 ^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                 ^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                 |
-   |                 temporary value does not live long enough
+   |                 creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13...
   --> $DIR/regions-creating-enums.rs:30:13
@@ -12,13 +12,13 @@ note: borrowed value must be valid for the lifetime 'a as defined on the functio
 LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize {
    |             ^^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-creating-enums.rs:38:17
    |
 LL |         return &ast::add(m_x, m_y);  //~ ERROR borrowed value does not live long enough
-   |                 ^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                 ^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                 |
-   |                 temporary value does not live long enough
+   |                 creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13...
   --> $DIR/regions-creating-enums.rs:30:13
@@ -28,4 +28,4 @@ LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usi
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr
index acf7a033ade..3bac4db3475 100644
--- a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr
+++ b/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr
@@ -1,11 +1,11 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-free-region-ordering-caller1.rs:19:27
    |
 LL |     let z: &'a & usize = &(&y);
-   |                           ^^^^ temporary value does not live long enough
+   |                           ^^^^ creates a temporary which is freed while still in use
 ...
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:10...
   --> $DIR/regions-free-region-ordering-caller1.rs:15:10
@@ -15,4 +15,4 @@ LL | fn call1<'a>(x: &'a usize) {
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr
new file mode 100644
index 00000000000..0a6b9b718b5
--- /dev/null
+++ b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr
@@ -0,0 +1,33 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:24:20
+   |
+LL |   let testValue = &id(Test);
+   |                    ^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:19...
+  --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:23:19
+   |
+LL | fn structLifetime<'a>() -> &'a Test {
+   |                   ^^
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:30:20
+   |
+LL |   let testValue = &id(MyEnum::Variant1);
+   |                    ^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+...
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+note: borrowed value must be valid for the lifetime 'a as defined on the function body at 29:20...
+  --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:29:20
+   |
+LL | fn variantLifetime<'a>() -> &'a MyEnum {
+   |                    ^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr b/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr
index 87fe858769d..af84d36e0b4 100644
--- a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr
+++ b/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr
@@ -1,22 +1,22 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-ref-in-fn-arg.rs:14:13
    |
 LL | fn arg_item(box ref x: Box<isize>) -> &'static isize {
-   |             ^^^^^^^^^ temporary value does not live long enough
+   |             ^^^^^^^^^ creates a temporary which is freed while still in use
 LL |     x //~^ ERROR borrowed value does not live long enough
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-ref-in-fn-arg.rs:21:11
    |
 LL |     with(|box ref x| x) //~ ERROR borrowed value does not live long enough
-   |           ^^^^^^^^^  - temporary value only lives until here
+   |           ^^^^^^^^^  - temporary value is freed at the end of this statement
    |           |
-   |           temporary value does not live long enough
+   |           creates a temporary which is freed while still in use
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-ret.nll.stderr b/src/test/ui/regions/regions-ret.nll.stderr
index cacc119d410..8dfb7c18480 100644
--- a/src/test/ui/regions/regions-ret.nll.stderr
+++ b/src/test/ui/regions/regions-ret.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-ret.rs:14:13
    |
 LL |     return &id(3); //~ ERROR borrowed value does not live long enough
-   |             ^^^^^- temporary value only lives until here
+   |             ^^^^^- temporary value is freed at the end of this statement
    |             |
-   |             temporary value does not live long enough
+   |             creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1...
   --> $DIR/regions-ret.rs:13:1
@@ -16,4 +16,4 @@ LL | | }
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr b/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr
new file mode 100644
index 00000000000..919e29e4ec4
--- /dev/null
+++ b/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr
@@ -0,0 +1,13 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/regions-return-stack-allocated-vec.rs:14:6
+   |
+LL |     &[x] //~ ERROR borrowed value does not live long enough
+   |      ^^^ creates a temporary which is freed while still in use
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr
index aa744a3ae8a..6d1b9938a8b 100644
--- a/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr
+++ b/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-var-type-out-of-scope.rs:19:14
    |
 LL |         x = &id(3); //~ ERROR borrowed value does not live long enough
-   |              ^^^^^- temporary value only lives until here
+   |              ^^^^^- temporary value is freed at the end of this statement
    |              |
-   |              temporary value does not live long enough
+   |              creates a temporary which is freed while still in use
 LL |         assert_eq!(*x, 3);
    |         ------------------ borrow later used here
    |
@@ -13,4 +13,4 @@ LL |         assert_eq!(*x, 3);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr
index 001eba4b039..765d8b36b0e 100644
--- a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr
+++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr
@@ -1,36 +1,36 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-let-suggestion-suffixes.rs:28:14
    |
 LL |     v3.push(&id('x'));           // statement 6
-   |              ^^^^^^^ - temporary value only lives until here
+   |              ^^^^^^^ - temporary value is freed at the end of this statement
    |              |
-   |              temporary value does not live long enough
+   |              creates a temporary which is freed while still in use
 ...
 LL |     (v1, v2, v3, /* v4 is above. */ v5).use_ref();
    |              -- borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-let-suggestion-suffixes.rs:38:18
    |
 LL |         v4.push(&id('y'));
-   |                  ^^^^^^^ - temporary value only lives until here
+   |                  ^^^^^^^ - temporary value is freed at the end of this statement
    |                  |
-   |                  temporary value does not live long enough
+   |                  creates a temporary which is freed while still in use
 ...
 LL |         v4.use_ref();
    |         -- borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/borrowck-let-suggestion-suffixes.rs:49:14
    |
 LL |     v5.push(&id('z'));
-   |              ^^^^^^^ - temporary value only lives until here
+   |              ^^^^^^^ - temporary value is freed at the end of this statement
    |              |
-   |              temporary value does not live long enough
+   |              creates a temporary which is freed while still in use
 ...
 LL |     (v1, v2, v3, /* v4 is above. */ v5).use_ref();
    |                                     -- borrow later used here
@@ -39,4 +39,4 @@ LL |     (v1, v2, v3, /* v4 is above. */ v5).use_ref();
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/span/issue-15480.nll.stderr b/src/test/ui/span/issue-15480.nll.stderr
index 8dcf486f830..098e1ce62a8 100644
--- a/src/test/ui/span/issue-15480.nll.stderr
+++ b/src/test/ui/span/issue-15480.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/issue-15480.rs:15:10
    |
 LL |         &id(3)
-   |          ^^^^^ temporary value does not live long enough
+   |          ^^^^^ creates a temporary which is freed while still in use
 LL |     ];
-   |      - temporary value only lives until here
+   |      - temporary value is freed at the end of this statement
 ...
 LL |     for &&x in &v {
    |                -- borrow later used here
@@ -13,4 +13,4 @@ LL |     for &&x in &v {
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr
index 3788b5a3284..0e5fc749d96 100644
--- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr
+++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr
@@ -1,11 +1,11 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:27
    |
 LL |         let ss: &isize = &id(1);
-   |                           ^^^^^ temporary value does not live long enough
+   |                           ^^^^^ creates a temporary which is freed while still in use
 ...
 LL |     }
-   |     - temporary value only lives until here
+   |     - temporary value is freed at the end of this statement
 LL | }
    | - borrow later used here, when `blah` is dropped
    |
@@ -13,4 +13,4 @@ LL | }
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/span/slice-borrow.nll.stderr b/src/test/ui/span/slice-borrow.nll.stderr
index 4a15d8ff455..0aeb549d95e 100644
--- a/src/test/ui/span/slice-borrow.nll.stderr
+++ b/src/test/ui/span/slice-borrow.nll.stderr
@@ -1,11 +1,11 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/slice-borrow.rs:16:28
    |
 LL |         let x: &[isize] = &vec![1, 2, 3, 4, 5];
-   |                            ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
 ...
 LL |     }
-   |     - temporary value only lives until here
+   |     - temporary value is freed at the end of this statement
 LL |     y.use_ref();
    |     - borrow later used here
    |
@@ -14,4 +14,4 @@ LL |     y.use_ref();
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/static/static-drop-scope.nll.stderr b/src/test/ui/static/static-drop-scope.nll.stderr
new file mode 100644
index 00000000000..36c645479dd
--- /dev/null
+++ b/src/test/ui/static/static-drop-scope.nll.stderr
@@ -0,0 +1,60 @@
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:19:60
+   |
+LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
+   |                                                            ^^^^^^^^ statics cannot evaluate destructors
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/static-drop-scope.rs:19:60
+   |
+LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
+   |                                                            ^^^^^^^^- temporary value is freed at the end of this statement
+   |                                                            |
+   |                                                            creates a temporary which is freed while still in use
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:23:59
+   |
+LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
+   |                                                           ^^^^^^^^ constants cannot evaluate destructors
+
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/static-drop-scope.rs:23:59
+   |
+LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
+   |                                                           ^^^^^^^^- temporary value is freed at the end of this statement
+   |                                                           |
+   |                                                           creates a temporary which is freed while still in use
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:27:28
+   |
+LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
+   |                            ^^^^^^^^^^^^^ statics cannot evaluate destructors
+
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:30:27
+   |
+LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
+   |                           ^^^^^^^^^^^^^ constants cannot evaluate destructors
+
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:33:24
+   |
+LL | const fn const_drop<T>(_: T) {}
+   |                        ^ constant functions cannot evaluate destructors
+
+error[E0493]: destructors cannot be evaluated at compile-time
+  --> $DIR/static-drop-scope.rs:37:5
+   |
+LL |     (x, ()).1
+   |     ^^^^^^^ constant functions cannot evaluate destructors
+
+error: aborting due to 8 previous errors
+
+Some errors occurred: E0493, E0714.
+For more information about an error, try `rustc --explain E0493`.
diff --git a/src/test/ui/static/static-reference-to-fn-2.nll.stderr b/src/test/ui/static/static-reference-to-fn-2.nll.stderr
index 9ef94189e90..3740d9051be 100644
--- a/src/test/ui/static/static-reference-to-fn-2.nll.stderr
+++ b/src/test/ui/static/static-reference-to-fn-2.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/static-reference-to-fn-2.rs:28:22
    |
 LL |     self_.statefn = &id(state2 as StateMachineFunc);
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                      |
-   |                      temporary value does not live long enough
+   |                      creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 27:1...
   --> $DIR/static-reference-to-fn-2.rs:27:1
@@ -16,13 +16,13 @@ LL | |     return Some("state1");
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/static-reference-to-fn-2.rs:34:22
    |
 LL |     self_.statefn = &id(state3 as StateMachineFunc);
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                      |
-   |                      temporary value does not live long enough
+   |                      creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 33:1...
   --> $DIR/static-reference-to-fn-2.rs:33:1
@@ -34,13 +34,13 @@ LL | |     return Some("state2");
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/static-reference-to-fn-2.rs:40:22
    |
 LL |     self_.statefn = &id(finished as StateMachineFunc);
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
    |                      |
-   |                      temporary value does not live long enough
+   |                      creates a temporary which is freed while still in use
    |
 note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 39:1...
   --> $DIR/static-reference-to-fn-2.rs:39:1
@@ -52,17 +52,17 @@ LL | |     return Some("state3");
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/static-reference-to-fn-2.rs:51:19
    |
 LL |         statefn: &id(state1 as StateMachineFunc)
-   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
 ...
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
    = note: borrowed value must be valid for the static lifetime...
 
 error: aborting due to 4 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/static/static-region-bound.nll.stderr b/src/test/ui/static/static-region-bound.nll.stderr
new file mode 100644
index 00000000000..3bb763eb1c7
--- /dev/null
+++ b/src/test/ui/static/static-region-bound.nll.stderr
@@ -0,0 +1,14 @@
+error[E0714]: temporary value dropped while borrowed
+  --> $DIR/static-region-bound.rs:20:14
+   |
+LL |     let x = &id(3); //~ ERROR borrowed value does not live long enough
+   |              ^^^^^ creates a temporary which is freed while still in use
+LL |     f(x);
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr b/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr
index 48a68bf5749..656a2eb698c 100644
--- a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr
+++ b/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr
@@ -1,10 +1,10 @@
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/wf-misc-methods-issue-28609.rs:32:31
    |
 LL |     s.transmute_inherent(&mut 42) //~ ERROR does not live long enough
-   |                               ^^ temporary value does not live long enough
+   |                               ^^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 30:1...
   --> $DIR/wf-misc-methods-issue-28609.rs:30:1
@@ -55,13 +55,13 @@ LL | |     &*s
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/wf-misc-methods-issue-28609.rs:63:15
    |
 LL |     s << &mut 3 //~ ERROR does not live long enough
-   |               ^ temporary value does not live long enough
+   |               ^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1...
   --> $DIR/wf-misc-methods-issue-28609.rs:61:1
@@ -72,13 +72,13 @@ LL | |     s << &mut 3 //~ ERROR does not live long enough
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/wf-misc-methods-issue-28609.rs:68:16
    |
 LL |     s.shl(&mut 3) //~ ERROR does not live long enough
-   |                ^ temporary value does not live long enough
+   |                ^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 66:1...
   --> $DIR/wf-misc-methods-issue-28609.rs:66:1
@@ -89,13 +89,13 @@ LL | |     s.shl(&mut 3) //~ ERROR does not live long enough
 LL | | }
    | |_^
 
-error[E0597]: borrowed value does not live long enough
+error[E0714]: temporary value dropped while borrowed
   --> $DIR/wf-misc-methods-issue-28609.rs:73:21
    |
 LL |     S2::shl(s, &mut 3) //~ ERROR does not live long enough
-   |                     ^ temporary value does not live long enough
+   |                     ^ creates a temporary which is freed while still in use
 LL | }
-   | - temporary value only lives until here
+   | - temporary value is freed at the end of this statement
    |
 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 71:1...
   --> $DIR/wf-misc-methods-issue-28609.rs:71:1
@@ -108,4 +108,5 @@ LL | | }
 
 error: aborting due to 6 previous errors
 
-For more information about this error, try `rustc --explain E0597`.
+Some errors occurred: E0597, E0714.
+For more information about an error, try `rustc --explain E0597`.