about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSunjay Varma <varma.sunjay@gmail.com>2017-12-13 18:50:45 -0500
committerSunjay Varma <varma.sunjay@gmail.com>2017-12-13 18:50:45 -0500
commitf701b4cca07d740d4d17c906ff982d40101ec09e (patch)
tree273e3ae6260230c5b5b15386882a7c6cd32479f5
parentb90e9c9b2cf04920c08569953c4e3ee5e339524b (diff)
downloadrust-f701b4cca07d740d4d17c906ff982d40101ec09e.tar.gz
rust-f701b4cca07d740d4d17c906ff982d40101ec09e.zip
Added test to make sure that undeclared lifetimes are in fact detected
-rw-r--r--src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs31
-rw-r--r--src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr32
2 files changed, 63 insertions, 0 deletions
diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs
new file mode 100644
index 00000000000..263b3cb42eb
--- /dev/null
+++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs
@@ -0,0 +1,31 @@
+// Copyright 2012 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.
+
+#![feature(generic_associated_types)]
+
+use std::ops::Deref;
+
+//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
+//follow-up PR
+
+trait Iterable {
+    type Item<'a>;
+    type Iter<'a>: Iterator<Item = Self::Item<'a>>
+    //~^ ERROR lifetime parameters are not allowed on this type [E0110]
+        + Deref<Target = Self::Item<'b>>;
+    //~^ ERROR undeclared lifetime
+    //~| ERROR lifetime parameters are not allowed on this type [E0110]
+
+    fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
+    //~^ ERROR undeclared lifetime
+    //~| ERROR lifetime parameters are not allowed on this type [E0110]
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr
new file mode 100644
index 00000000000..587be7113ce
--- /dev/null
+++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr
@@ -0,0 +1,32 @@
+error[E0261]: use of undeclared lifetime name `'b`
+  --> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
+   |
+22 |         + Deref<Target = Self::Item<'b>>;
+   |                                     ^^ undeclared lifetime
+
+error[E0261]: use of undeclared lifetime name `'undeclared`
+  --> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
+   |
+26 |     fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
+   |                                         ^^^^^^^^^^^ undeclared lifetime
+
+error[E0110]: lifetime parameters are not allowed on this type
+  --> $DIR/generic_associated_type_undeclared_lifetimes.rs:20:47
+   |
+20 |     type Iter<'a>: Iterator<Item = Self::Item<'a>>
+   |                                               ^^ lifetime parameter not allowed on this type
+
+error[E0110]: lifetime parameters are not allowed on this type
+  --> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
+   |
+22 |         + Deref<Target = Self::Item<'b>>;
+   |                                     ^^ lifetime parameter not allowed on this type
+
+error[E0110]: lifetime parameters are not allowed on this type
+  --> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
+   |
+26 |     fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
+   |                                         ^^^^^^^^^^^ lifetime parameter not allowed on this type
+
+error: aborting due to 5 previous errors
+