summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/ty-outlives/projection-where-clause-none.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/nll/ty-outlives/projection-where-clause-none.rs')
-rw-r--r--tests/ui/nll/ty-outlives/projection-where-clause-none.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-none.rs b/tests/ui/nll/ty-outlives/projection-where-clause-none.rs
new file mode 100644
index 000000000..bb201e5c0
--- /dev/null
+++ b/tests/ui/nll/ty-outlives/projection-where-clause-none.rs
@@ -0,0 +1,24 @@
+// Test that we are NOT able to establish that `<T as
+// MyTrait<'a>>::Output: 'a` outlives `'a` here -- we have only one
+// recourse, which is to prove that `T: 'a` and `'a: 'a`, but we don't
+// know that `T: 'a`.
+
+trait MyTrait<'a> {
+ type Output;
+}
+
+fn foo<'a, T>() -> &'a ()
+where
+ T: MyTrait<'a>,
+{
+ bar::<T::Output>() //~ ERROR the parameter type `T` may not live long enough
+}
+
+fn bar<'a, T>() -> &'a ()
+where
+ T: 'a,
+{
+ &()
+}
+
+fn main() {}