about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-10-18 14:26:33 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-10-19 09:34:28 -0400
commit16b3ea1e2e690524796b37a4b4e2f88e60a9dc3e (patch)
treebc534effbedea738cd6a416c88a0f1f17bbc6c02
parent820c2657f2584501d5e062351306780d29385421 (diff)
downloadrust-16b3ea1e2e690524796b37a4b4e2f88e60a9dc3e.tar.gz
rust-16b3ea1e2e690524796b37a4b4e2f88e60a9dc3e.zip
add a test that we enforce '`static` errors post normalization
-rw-r--r--src/test/ui/nll/user-annotations/normalization.rs13
-rw-r--r--src/test/ui/nll/user-annotations/normalization.stderr13
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/nll/user-annotations/normalization.rs b/src/test/ui/nll/user-annotations/normalization.rs
new file mode 100644
index 00000000000..51d9adccd73
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/normalization.rs
@@ -0,0 +1,13 @@
+// Test that we enforce a `&'static` requirement that is only visible
+// after normalization.
+
+#![feature(nll)]
+#![ignore(unused)]
+
+trait Foo { type Out; }
+impl Foo for () { type Out = &'static u32; }
+
+fn main() {
+    let a = 22;
+    let b: <() as Foo>::Out = &a; //~ ERROR
+}
diff --git a/src/test/ui/nll/user-annotations/normalization.stderr b/src/test/ui/nll/user-annotations/normalization.stderr
new file mode 100644
index 00000000000..489f9feb044
--- /dev/null
+++ b/src/test/ui/nll/user-annotations/normalization.stderr
@@ -0,0 +1,13 @@
+error[E0597]: `a` does not live long enough
+  --> $DIR/normalization.rs:12:31
+   |
+LL |     let b: <() as Foo>::Out = &a; //~ ERROR
+   |                               ^^ borrowed value does not live long enough
+LL | }
+   | - `a` 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`.