about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs19
-rw-r--r--src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr13
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs
new file mode 100644
index 00000000000..2785f71ebcf
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs
@@ -0,0 +1,19 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![allow(warnings)]
+#![feature(nll)]
+#![feature(type_ascription)]
+
+fn main() {
+    let x = 22_u32;
+    let y: &u32 = &x: &'static u32; //~ ERROR E0597
+}
diff --git a/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr
new file mode 100644
index 00000000000..2303ed64db9
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr
@@ -0,0 +1,13 @@
+error[E0597]: `x` does not live long enough
+  --> $DIR/type_ascription_static_lifetime.rs:18:19
+   |
+LL |     let y: &u32 = &x: &'static u32; //~ ERROR E0597
+   |                   ^^ borrowed value does not live long enough
+LL | }
+   | - `x` dropped here while still borrowed
+   |
+   = 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`.