about summary refs log tree commit diff
path: root/src/test/ui/static
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 /src/test/ui/static
parentae366637fedf6f34185e54fc7b2d725b1a458ff6 (diff)
downloadrust-5fc0b743d752f57d39cbd7ff10450211affe79a0.tar.gz
rust-5fc0b743d752f57d39cbd7ff10450211affe79a0.zip
add "temporary value dropped while borrowed" error
Issue #54131
Diffstat (limited to 'src/test/ui/static')
-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
3 files changed, 87 insertions, 13 deletions
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`.