summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfc-2093-infer-outlives
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/rfc-2093-infer-outlives
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/rfc-2093-infer-outlives')
-rw-r--r--tests/ui/rfc-2093-infer-outlives/cross-crate.rs8
-rw-r--r--tests/ui/rfc-2093-infer-outlives/cross-crate.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs12
-rw-r--r--tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr19
-rw-r--r--tests/ui/rfc-2093-infer-outlives/enum.rs27
-rw-r--r--tests/ui/rfc-2093-infer-outlives/enum.stderr26
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs12
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-enum.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-projection.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-struct.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-union.rs14
-rw-r--r--tests/ui/rfc-2093-infer-outlives/explicit-union.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/issue-54467.rs17
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-enum.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-enum.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-regions.rs8
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-regions.stderr12
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-structs.rs12
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-structs.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-union.rs14
-rw-r--r--tests/ui/rfc-2093-infer-outlives/nested-union.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/privacy.rs20
-rw-r--r--tests/ui/rfc-2093-infer-outlives/projection.rs8
-rw-r--r--tests/ui/rfc-2093-infer-outlives/projection.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/reference.rs8
-rw-r--r--tests/ui/rfc-2093-infer-outlives/reference.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs39
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr36
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs22
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr20
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs22
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr20
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs22
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr20
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs22
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr20
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs28
-rw-r--r--tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr48
-rw-r--r--tests/ui/rfc-2093-infer-outlives/self-dyn.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/self-dyn.stderr10
-rw-r--r--tests/ui/rfc-2093-infer-outlives/self-structs.rs13
-rw-r--r--tests/ui/rfc-2093-infer-outlives/self-structs.stderr10
46 files changed, 744 insertions, 0 deletions
diff --git a/tests/ui/rfc-2093-infer-outlives/cross-crate.rs b/tests/ui/rfc-2093-infer-outlives/cross-crate.rs
new file mode 100644
index 000000000..a9bfeabf1
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/cross-crate.rs
@@ -0,0 +1,8 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, T> { //~ ERROR rustc_outlives
+ bar: std::slice::IterMut<'a, T>
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr b/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr
new file mode 100644
index 000000000..76300cce5
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/cross-crate.rs:4:1
+ |
+LL | struct Foo<'a, T> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs
new file mode 100644
index 000000000..d3940b13b
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs
@@ -0,0 +1,12 @@
+/*
+ * We don't infer `T: 'static` outlives relationships.
+ */
+
+struct Foo<U> {
+ bar: Bar<U> //~ ERROR the parameter type `U` may not live long enough [E0310]
+}
+struct Bar<T: 'static> {
+ x: T,
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
new file mode 100644
index 000000000..0c388f5fe
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
@@ -0,0 +1,19 @@
+error[E0310]: the parameter type `U` may not live long enough
+ --> $DIR/dont-infer-static.rs:6:10
+ |
+LL | bar: Bar<U>
+ | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/dont-infer-static.rs:8:15
+ |
+LL | struct Bar<T: 'static> {
+ | ^^^^^^^
+help: consider adding an explicit lifetime bound...
+ |
+LL | struct Foo<U: 'static> {
+ | +++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.
diff --git a/tests/ui/rfc-2093-infer-outlives/enum.rs b/tests/ui/rfc-2093-infer-outlives/enum.rs
new file mode 100644
index 000000000..71d2d3222
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/enum.rs
@@ -0,0 +1,27 @@
+#![feature(rustc_attrs)]
+
+// Needs an explicit where clause stating outlives condition. (RFC 2093)
+
+// Type T needs to outlive lifetime 'a.
+#[rustc_outlives]
+enum Foo<'a, T> { //~ ERROR rustc_outlives
+ One(Bar<'a, T>)
+}
+
+// Type U needs to outlive lifetime 'b
+#[rustc_outlives]
+struct Bar<'b, U> { //~ ERROR rustc_outlives
+ field2: &'b U
+}
+
+// Type K needs to outlive lifetime 'c.
+#[rustc_outlives]
+enum Ying<'c, K> { //~ ERROR rustc_outlives
+ One(&'c Yang<K>)
+}
+
+struct Yang<V> {
+ field2: V
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/enum.stderr b/tests/ui/rfc-2093-infer-outlives/enum.stderr
new file mode 100644
index 000000000..b6ce2450e
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/enum.stderr
@@ -0,0 +1,26 @@
+error: rustc_outlives
+ --> $DIR/enum.rs:7:1
+ |
+LL | enum Foo<'a, T> {
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: rustc_outlives
+ --> $DIR/enum.rs:13:1
+ |
+LL | struct Bar<'b, U> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: U: 'b
+
+error: rustc_outlives
+ --> $DIR/enum.rs:19:1
+ |
+LL | enum Ying<'c, K> {
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: K: 'c
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs
new file mode 100644
index 000000000..419fb0a0e
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs
@@ -0,0 +1,12 @@
+#![feature(rustc_attrs)]
+
+trait Trait<'x, T> where T: 'x {
+}
+
+#[rustc_outlives]
+struct Foo<'a, A> //~ ERROR rustc_outlives
+{
+ foo: Box<dyn Trait<'a, A>>
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr
new file mode 100644
index 000000000..595a5c280
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/explicit-dyn.rs:7:1
+ |
+LL | struct Foo<'a, A>
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: A: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs b/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs
new file mode 100644
index 000000000..c330c27fe
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+enum Foo<'a, U> { //~ ERROR rustc_outlives
+ One(Bar<'a, U>)
+}
+
+struct Bar<'x, T> where T: 'x {
+ x: &'x (),
+ y: T,
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr
new file mode 100644
index 000000000..3059f95ae
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/explicit-enum.rs:4:1
+ |
+LL | enum Foo<'a, U> {
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: U: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs b/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs
new file mode 100644
index 000000000..00b895288
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+trait Trait<'x, T> where T: 'x {
+ type Type;
+}
+
+#[rustc_outlives]
+struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives
+{
+ foo: <A as Trait<'a, B>>::Type
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr
new file mode 100644
index 000000000..589e95899
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/explicit-projection.rs:8:1
+ |
+LL | struct Foo<'a, A, B> where A: Trait<'a, B>
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: B: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs b/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs
new file mode 100644
index 000000000..3d5e610b9
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'b, U> { //~ ERROR rustc_outlives
+ bar: Bar<'b, U>
+}
+
+struct Bar<'a, T> where T: 'a {
+ x: &'a (),
+ y: T,
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr
new file mode 100644
index 000000000..9912e36b2
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/explicit-struct.rs:4:1
+ |
+LL | struct Foo<'b, U> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: U: 'b
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-union.rs b/tests/ui/rfc-2093-infer-outlives/explicit-union.rs
new file mode 100644
index 000000000..871208b5b
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-union.rs
@@ -0,0 +1,14 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+union Foo<'b, U: Copy> { //~ ERROR rustc_outlives
+ bar: Bar<'b, U>
+}
+
+#[derive(Clone, Copy)]
+union Bar<'a, T: Copy> where T: 'a {
+ x: &'a (),
+ y: T,
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr
new file mode 100644
index 000000000..16b64bdc2
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/explicit-union.rs:4:1
+ |
+LL | union Foo<'b, U: Copy> {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: U: 'b
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/issue-54467.rs b/tests/ui/rfc-2093-infer-outlives/issue-54467.rs
new file mode 100644
index 000000000..c712f15e3
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/issue-54467.rs
@@ -0,0 +1,17 @@
+// Regression test for #54467:
+//
+// Here, the trait object has an "inferred outlives" requirement that
+// `<Self as MyIterator<'a>>::Item: 'a`; but since we don't know what
+// `Self` is, we were (incorrectly) messing things up, leading to
+// strange errors. This test ensures that we do not give compilation
+// errors.
+//
+// check-pass
+
+trait MyIterator<'a>: Iterator where Self::Item: 'a { }
+
+struct MyStruct<'a, A> {
+ item: Box<dyn MyIterator<'a, Item = A>>
+}
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-enum.rs b/tests/ui/rfc-2093-infer-outlives/nested-enum.rs
new file mode 100644
index 000000000..0cd706e7a
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-enum.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+enum Foo<'a, T> { //~ ERROR rustc_outlives
+
+ One(Bar<'a, T>)
+}
+
+struct Bar<'b, U> {
+ field2: &'b U
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr b/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr
new file mode 100644
index 000000000..4350e6e8b
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/nested-enum.rs:4:1
+ |
+LL | enum Foo<'a, T> {
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-regions.rs b/tests/ui/rfc-2093-infer-outlives/nested-regions.rs
new file mode 100644
index 000000000..a01c50681
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-regions.rs
@@ -0,0 +1,8 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives
+ x: &'a &'b T
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr b/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr
new file mode 100644
index 000000000..c08add7ed
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr
@@ -0,0 +1,12 @@
+error: rustc_outlives
+ --> $DIR/nested-regions.rs:4:1
+ |
+LL | struct Foo<'a, 'b, T> {
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: 'b: 'a
+ = note: T: 'a
+ = note: T: 'b
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-structs.rs b/tests/ui/rfc-2093-infer-outlives/nested-structs.rs
new file mode 100644
index 000000000..ac6817d22
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-structs.rs
@@ -0,0 +1,12 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, T> { //~ ERROR rustc_outlives
+ field1: Bar<'a, T>
+}
+
+struct Bar<'b, U> {
+ field2: &'b U
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr b/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr
new file mode 100644
index 000000000..769555234
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/nested-structs.rs:4:1
+ |
+LL | struct Foo<'a, T> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-union.rs b/tests/ui/rfc-2093-infer-outlives/nested-union.rs
new file mode 100644
index 000000000..27ebd0b54
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-union.rs
@@ -0,0 +1,14 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+union Foo<'a, T: Copy> { //~ ERROR rustc_outlives
+ field1: Bar<'a, T>
+}
+
+// Type U needs to outlive lifetime 'b
+#[derive(Clone, Copy)]
+union Bar<'b, U: Copy> {
+ field2: &'b U
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/nested-union.stderr b/tests/ui/rfc-2093-infer-outlives/nested-union.stderr
new file mode 100644
index 000000000..a785c63ce
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/nested-union.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/nested-union.rs:4:1
+ |
+LL | union Foo<'a, T: Copy> {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/privacy.rs b/tests/ui/rfc-2093-infer-outlives/privacy.rs
new file mode 100644
index 000000000..180f5ac6c
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/privacy.rs
@@ -0,0 +1,20 @@
+// Test that we do not get a privacy error here. Initially, we did,
+// because we inferred an outlives predciate of `<Foo<'a> as
+// Private>::Out: 'a`, but the private trait is -- well -- private,
+// and hence it was not something that a pub trait could refer to.
+//
+// run-pass
+
+#![allow(dead_code)]
+
+pub struct Foo<'a> {
+ field: Option<&'a <Foo<'a> as Private>::Out>
+}
+
+trait Private {
+ type Out: ?Sized;
+}
+
+impl<T: ?Sized> Private for T { type Out = Self; }
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/projection.rs b/tests/ui/rfc-2093-infer-outlives/projection.rs
new file mode 100644
index 000000000..411c86da1
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/projection.rs
@@ -0,0 +1,8 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives
+ bar: &'a T::Item
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/projection.stderr b/tests/ui/rfc-2093-infer-outlives/projection.stderr
new file mode 100644
index 000000000..d9342013f
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/projection.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/projection.rs:4:1
+ |
+LL | struct Foo<'a, T: Iterator> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: <T as Iterator>::Item: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/reference.rs b/tests/ui/rfc-2093-infer-outlives/reference.rs
new file mode 100644
index 000000000..a48a3315a
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/reference.rs
@@ -0,0 +1,8 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, T> { //~ ERROR rustc_outlives
+ bar: &'a T,
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/reference.stderr b/tests/ui/rfc-2093-infer-outlives/reference.stderr
new file mode 100644
index 000000000..508114357
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/reference.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/reference.rs:4:1
+ |
+LL | struct Foo<'a, T> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs
new file mode 100644
index 000000000..8b491ee4e
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs
@@ -0,0 +1,39 @@
+// Various examples of structs whose fields are not well-formed.
+
+#![allow(dead_code)]
+
+trait Dummy<'a> {
+ type Out;
+}
+impl<'a, T> Dummy<'a> for T
+where
+ T: 'a,
+{
+ type Out = ();
+}
+type RequireOutlives<'a, T> = <T as Dummy<'a>>::Out;
+
+enum Ref1<'a, T> {
+ Ref1Variant1(RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
+}
+
+enum Ref2<'a, T> {
+ Ref2Variant1,
+ Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
+}
+
+enum RefOk<'a, T: 'a> {
+ RefOkVariant1(&'a T),
+}
+
+// This is now well formed. RFC 2093
+enum RefIndirect<'a, T> {
+ RefIndirectVariant1(isize, RefOk<'a, T>),
+}
+
+enum RefDouble<'a, 'b, T> {
+ RefDoubleVariant1(&'a RequireOutlives<'b, T>),
+ //~^ the parameter type `T` may not live long enough [E0309]
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr
new file mode 100644
index 000000000..2c660b285
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr
@@ -0,0 +1,36 @@
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/regions-enum-not-wf.rs:17:18
+ |
+LL | Ref1Variant1(RequireOutlives<'a, T>),
+ | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | enum Ref1<'a, T: 'a> {
+ | ++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/regions-enum-not-wf.rs:22:25
+ |
+LL | Ref2Variant2(isize, RequireOutlives<'a, T>),
+ | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | enum Ref2<'a, T: 'a> {
+ | ++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/regions-enum-not-wf.rs:35:23
+ |
+LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>),
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | enum RefDouble<'a, 'b, T: 'b> {
+ | ++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs
new file mode 100644
index 000000000..36b024d2e
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs
@@ -0,0 +1,22 @@
+// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
+// arguments (like `'a`) outlive `'b`.
+//
+// Rule OutlivesNominalType from RFC 1214.
+
+
+#![allow(dead_code)]
+
+mod rev_variant_struct_region {
+ struct Foo<'a> {
+ x: fn(&'a i32),
+ }
+ trait Trait<'a, 'b> {
+ type Out;
+ }
+ impl<'a, 'b> Trait<'a, 'b> for usize {
+ type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime
+ }
+}
+
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr
new file mode 100644
index 000000000..5dff4c8ff
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr
@@ -0,0 +1,20 @@
+error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references
+ --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20
+ |
+LL | type Out = &'a Foo<'b>;
+ | ^^^^^^^^^^^
+ |
+note: the pointer is valid for the lifetime `'a` as defined here
+ --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+note: but the referenced data is only valid for the lifetime `'b` as defined here
+ --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:14
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs
new file mode 100644
index 000000000..47a38f7c4
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs
@@ -0,0 +1,22 @@
+// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
+// arguments (like `'a`) outlive `'b`.
+//
+// Rule OutlivesNominalType from RFC 1214.
+
+
+#![allow(dead_code)]
+
+mod variant_struct_region {
+ struct Foo<'a> {
+ x: &'a i32,
+ }
+ trait Trait<'a, 'b> {
+ type Out;
+ }
+ impl<'a, 'b> Trait<'a, 'b> for usize {
+ type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime
+ }
+}
+
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr
new file mode 100644
index 000000000..975776cdd
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr
@@ -0,0 +1,20 @@
+error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references
+ --> $DIR/regions-outlives-nominal-type-region.rs:17:20
+ |
+LL | type Out = &'a Foo<'b>;
+ | ^^^^^^^^^^^
+ |
+note: the pointer is valid for the lifetime `'a` as defined here
+ --> $DIR/regions-outlives-nominal-type-region.rs:16:10
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+note: but the referenced data is only valid for the lifetime `'b` as defined here
+ --> $DIR/regions-outlives-nominal-type-region.rs:16:14
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs
new file mode 100644
index 000000000..083ba8948
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs
@@ -0,0 +1,22 @@
+// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
+// arguments (like `'a`) outlive `'b`.
+//
+// Rule OutlivesNominalType from RFC 1214.
+
+
+#![allow(dead_code)]
+
+mod variant_struct_type {
+ struct Foo<T> {
+ x: fn(T)
+ }
+ trait Trait<'a, 'b> {
+ type Out;
+ }
+ impl<'a, 'b> Trait<'a, 'b> for usize {
+ type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime
+ }
+}
+
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr
new file mode 100644
index 000000000..be05ecec0
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr
@@ -0,0 +1,20 @@
+error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references
+ --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20
+ |
+LL | type Out = &'a Foo<&'b i32>;
+ | ^^^^^^^^^^^^^^^^
+ |
+note: the pointer is valid for the lifetime `'a` as defined here
+ --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+note: but the referenced data is only valid for the lifetime `'b` as defined here
+ --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:14
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs
new file mode 100644
index 000000000..f3e4e39ac
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs
@@ -0,0 +1,22 @@
+// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
+// arguments (like `'a`) outlive `'b`.
+//
+// Rule OutlivesNominalType from RFC 1214.
+
+
+#![allow(dead_code)]
+
+mod variant_struct_type {
+ struct Foo<T> {
+ x: T
+ }
+ trait Trait<'a, 'b> {
+ type Out;
+ }
+ impl<'a, 'b> Trait<'a, 'b> for usize {
+ type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime
+ }
+}
+
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr
new file mode 100644
index 000000000..4ba1778d6
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr
@@ -0,0 +1,20 @@
+error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references
+ --> $DIR/regions-outlives-nominal-type-type.rs:17:20
+ |
+LL | type Out = &'a Foo<&'b i32>;
+ | ^^^^^^^^^^^^^^^^
+ |
+note: the pointer is valid for the lifetime `'a` as defined here
+ --> $DIR/regions-outlives-nominal-type-type.rs:16:10
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+note: but the referenced data is only valid for the lifetime `'b` as defined here
+ --> $DIR/regions-outlives-nominal-type-type.rs:16:14
+ |
+LL | impl<'a, 'b> Trait<'a, 'b> for usize {
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs
new file mode 100644
index 000000000..552c6cf00
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs
@@ -0,0 +1,28 @@
+// Various examples of structs whose fields are not well-formed.
+
+#![allow(dead_code)]
+
+trait Trait<'a, T> {
+ type Out;
+}
+trait Trait1<'a, 'b, T> {
+ type Out;
+}
+
+impl<'a, T> Trait<'a, T> for usize {
+ type Out = &'a T; //~ ERROR `T` may not live long enough
+}
+
+struct RefOk<'a, T:'a> {
+ field: &'a T
+}
+
+impl<'a, T> Trait<'a, T> for u32 {
+ type Out = RefOk<'a, T>; //~ ERROR `T` may not live long enough
+}
+
+impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 {
+ type Out = &'a &'b T; //~ ERROR reference has a longer lifetime than the data
+}
+
+fn main() { }
diff --git a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr
new file mode 100644
index 000000000..34ff1362c
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr
@@ -0,0 +1,48 @@
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/regions-struct-not-wf.rs:13:16
+ |
+LL | type Out = &'a T;
+ | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | impl<'a, T: 'a> Trait<'a, T> for usize {
+ | ++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/regions-struct-not-wf.rs:21:16
+ |
+LL | type Out = RefOk<'a, T>;
+ | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/regions-struct-not-wf.rs:16:20
+ |
+LL | struct RefOk<'a, T:'a> {
+ | ^^
+help: consider adding an explicit lifetime bound...
+ |
+LL | impl<'a, T: 'a> Trait<'a, T> for u32 {
+ | ++++
+
+error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references
+ --> $DIR/regions-struct-not-wf.rs:25:16
+ |
+LL | type Out = &'a &'b T;
+ | ^^^^^^^^^
+ |
+note: the pointer is valid for the lifetime `'a` as defined here
+ --> $DIR/regions-struct-not-wf.rs:24:6
+ |
+LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 {
+ | ^^
+note: but the referenced data is only valid for the lifetime `'b` as defined here
+ --> $DIR/regions-struct-not-wf.rs:24:10
+ |
+LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 {
+ | ^^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0309, E0491.
+For more information about an error, try `rustc --explain E0309`.
diff --git a/tests/ui/rfc-2093-infer-outlives/self-dyn.rs b/tests/ui/rfc-2093-infer-outlives/self-dyn.rs
new file mode 100644
index 000000000..c53d6c18f
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/self-dyn.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+trait Trait<'x, 's, T> where T: 'x,
+ 's: {
+}
+
+#[rustc_outlives]
+struct Foo<'a, 'b, A> //~ ERROR rustc_outlives
+{
+ foo: Box<dyn Trait<'a, 'b, A>>
+}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr b/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr
new file mode 100644
index 000000000..9c836b190
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/self-dyn.rs:8:1
+ |
+LL | struct Foo<'a, 'b, A>
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: A: 'a
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfc-2093-infer-outlives/self-structs.rs b/tests/ui/rfc-2093-infer-outlives/self-structs.rs
new file mode 100644
index 000000000..8f2d29d6f
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/self-structs.rs
@@ -0,0 +1,13 @@
+#![feature(rustc_attrs)]
+
+#[rustc_outlives]
+struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives
+ field1: dyn Bar<'a, 'b, T>
+}
+
+trait Bar<'x, 's, U>
+ where U: 'x,
+ Self:'s
+{}
+
+fn main() {}
diff --git a/tests/ui/rfc-2093-infer-outlives/self-structs.stderr b/tests/ui/rfc-2093-infer-outlives/self-structs.stderr
new file mode 100644
index 000000000..2b4625f77
--- /dev/null
+++ b/tests/ui/rfc-2093-infer-outlives/self-structs.stderr
@@ -0,0 +1,10 @@
+error: rustc_outlives
+ --> $DIR/self-structs.rs:4:1
+ |
+LL | struct Foo<'a, 'b, T> {
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: T: 'a
+
+error: aborting due to previous error
+