about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-02-27 22:21:49 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2019-03-01 18:53:16 +0000
commit3b93d71fd200d5f2f39f1c4a7a4b09cb19ff64be (patch)
tree6d14e6d62da9300b9379c80f15e88c883e820de5 /src/test
parent848c25207208d3ad71e6d4fd3719cc7dc725bdf4 (diff)
Handle type annotations in promoted MIR correctly
Type annotations are shared between the MIR of a function and the
promoted constants for that function, so keep them in the type checker
when we check the promoted MIR.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/nll/user-annotations/promoted-annotation.rs12
-rw-r--r--src/test/ui/nll/user-annotations/promoted-annotation.stderr17
2 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/nll/user-annotations/promoted-annotation.rs b/src/test/ui/nll/user-annotations/promoted-annotation.rs
new file mode 100644
index 00000000000..fa2d2fb8118
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/promoted-annotation.rs
@@ -0,0 +1,12 @@
+// Test that type annotations are checked in promoted constants correctly.
+
+#![feature(nll)]
+
+fn foo<'a>() {
+    let x = 0;
+    let f = &drop::<&'a i32>;
+    f(&x);
+    //~^ ERROR `x` does not live long enough
+}
+
+fn main() {}
diff --git a/src/test/ui/nll/user-annotations/promoted-annotation.stderr b/src/test/ui/nll/user-annotations/promoted-annotation.stderr
new file mode 100644
index 00000000000..144af1e0ec1
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/promoted-annotation.stderr
@@ -0,0 +1,17 @@
+error[E0597]: `x` does not live long enough
+  --> $DIR/promoted-annotation.rs:8:7
+   |
+LL | fn foo<'a>() {
+   |        -- lifetime `'a` defined here
+LL |     let x = 0;
+LL |     let f = &drop::<&'a i32>;
+   |             ---------------- assignment requires that `x` is borrowed for `'a`
+LL |     f(&x);
+   |       ^^ borrowed value does not live long enough
+LL |     //~^ ERROR `x` does not live long enough
+LL | }
+   | - `x` dropped here while still borrowed
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.