about summary refs log tree commit diff
path: root/src/test/ui/lifetimes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-16 09:12:04 +0000
committerbors <bors@rust-lang.org>2017-12-16 09:12:04 +0000
commitbdae618418abc58a1da5e565f2b124cdfebb5682 (patch)
tree10a38e8bb89b1a584a78b45131f992e40730fe4a /src/test/ui/lifetimes
parent00fbfcce961c9e2acb82473234140a376e093a7a (diff)
parent2679944653bb7ef1690840cc177da9896daa2963 (diff)
downloadrust-bdae618418abc58a1da5e565f2b124cdfebb5682.tar.gz
rust-bdae618418abc58a1da5e565f2b124cdfebb5682.zip
Auto merge of #46722 - arielb1:single-self, r=eddyb
fix broken assertion in type_param

Nested generics (aka method generics) in trait methods don't have an
*additional* Self parameter in their own type parameter list (they have
a Self parameter in the parent generics), so don't try to check we're
correctly adjusting for it.

Fixes #46568.

r? @eddyb
Diffstat (limited to 'src/test/ui/lifetimes')
-rw-r--r--src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs8
-rw-r--r--src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr63
2 files changed, 49 insertions, 22 deletions
diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs
index 58c33af0ddd..0099a8bc10f 100644
--- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs
+++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs
@@ -33,11 +33,19 @@ struct Foo<T> {
 trait X<K>: Sized {
     fn foo<'a, L: X<&'a Nested<K>>>();
     //~^ ERROR may not live long enough
+
     // check that we give a sane error for `Self`
     fn bar<'a, L: X<&'a Nested<Self>>>();
     //~^ ERROR may not live long enough
+
+    // check that we give a sane error for nested generics
+    fn baz<'a, L, M: X<&'a Nested<L>>>() {
+        //~^ ERROR may not live long enough
+    }
 }
 
+trait TraitB {}
+
 struct Nested<K>(K);
 impl<K> Nested<K> {
     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
index 342c6ab8f16..05908606da7 100644
--- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
+++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
@@ -41,54 +41,73 @@ note: ...so that the reference type `&'a Nested<K>` does not outlive the data it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:37:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:38:5
    |
-37 |     fn bar<'a, L: X<&'a Nested<Self>>>();
+38 |     fn bar<'a, L: X<&'a Nested<Self>>>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider adding an explicit lifetime bound `Self: 'a`...
 note: ...so that the reference type `&'a Nested<Self>` does not outlive the data it points at
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:37:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:38:5
    |
-37 |     fn bar<'a, L: X<&'a Nested<Self>>>();
+38 |     fn bar<'a, L: X<&'a Nested<Self>>>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+error[E0309]: the parameter type `L` may not live long enough
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:42:5
+   |
+42 |       fn baz<'a, L, M: X<&'a Nested<L>>>() {
+   |       ^          - help: consider adding an explicit lifetime bound `L: 'a`...
+   |  _____|
+   | |
+43 | |         //~^ ERROR may not live long enough
+44 | |     }
+   | |_____^
+   |
+note: ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:42:5
+   |
+42 | /     fn baz<'a, L, M: X<&'a Nested<L>>>() {
+43 | |         //~^ ERROR may not live long enough
+44 | |     }
+   | |_____^
+
 error[E0309]: the parameter type `K` may not live long enough
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:43:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:51:5
    |
-42 |   impl<K> Nested<K> {
+50 |   impl<K> Nested<K> {
    |        - help: consider adding an explicit lifetime bound `K: 'a`...
-43 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
-44 | |         //~^ ERROR may not live long enough
-45 | |     }
+51 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
+52 | |         //~^ ERROR may not live long enough
+53 | |     }
    | |_____^
    |
 note: ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:43:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:51:5
    |
-43 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
-44 | |         //~^ ERROR may not live long enough
-45 | |     }
+51 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
+52 | |         //~^ ERROR may not live long enough
+53 | |     }
    | |_____^
 
 error[E0309]: the parameter type `M` may not live long enough
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:46:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:54:5
    |
-46 |       fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
+54 |       fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
    |       ^                                                -- help: consider adding an explicit lifetime bound `M: 'a`...
    |  _____|
    | |
-47 | |         //~^ ERROR may not live long enough
-48 | |     }
+55 | |         //~^ ERROR may not live long enough
+56 | |     }
    | |_____^
    |
 note: ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
-  --> $DIR/lifetime-doesnt-live-long-enough.rs:46:5
+  --> $DIR/lifetime-doesnt-live-long-enough.rs:54:5
    |
-46 | /     fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
-47 | |         //~^ ERROR may not live long enough
-48 | |     }
+54 | /     fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
+55 | |         //~^ ERROR may not live long enough
+56 | |     }
    | |_____^
 
-error: aborting due to 6 previous errors
+error: aborting due to 7 previous errors