Change:
When using to build one of my projects, I got the error I tried to minimize my code and got to . : with the command I got the error : : backtrace :
I can reproduce this with:

Discussion:
if let Some(idx) = param.idx.checked_sub(self.parent_count() as u32) { // non-Self type parameters are always offset by exactly // `self.regions.len()`. In the absence of a Self, this is obvious, <del> // but even in the absence of a `Self` we just have to "compensate" </del> <ins> // but even in the presence of a `Self` we just have to "compensate" </ins> // for the regions: // <del> // For example, for `trait Foo<'a, 'b, T1, T2>`, the </del> <ins> // Without a `Self` (or in a nested generics that doesn't have // a `Self` in itself, even through it parent does), for example // for `fn foo<'a, T1, T2>()`, the situation is: //     Substs: //         0  1  2 //         'a T1 T2 //     generics.types: //         0  1 //         T1 T2 // // And with a `Self`, for example for `trait Foo<'a, 'b, T1, T2>`, the </ins> // situation is: //     Substs: //         0   1  2  3  4

//     generics.types: //         0  1  2 //       Self T1 T2 <del> // And it can be seen that to move from a substs offset to a // generics offset you just have to offset by the number of regions. </del> <ins> // // And it can be seen that in both cases, to move from a substs // offset to a generics offset you just have to offset by the // number of regions. </ins> let type_param_offset = self.regions.len(); <ins> let has_self = self.has_self && self.parent.is_none(); let is_separated_self = type_param_offset != 0 && idx == 0 && has_self; </ins> if let Some(idx) = (idx as usize).checked_sub(type_param_offset) { <del> assert!(!(self.has_self && idx == 0)); </del> <ins> assert!(!is_separated_self, "found a Self after type_param_offset"); </ins> &self.types[idx] } else { <del> assert!(self.has_self && idx == 0); </del> <ins> assert!(is_separated_self, "non-Self param before type_param_offset"); </ins> &self.types[0] } } else {

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 <ins> // 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 } </ins> } <ins> trait TraitB {} </ins> struct Nested<K>(K); impl<K> Nested<K> { fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {

|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `Self` may not live long enough <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:37:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:38:5 </ins> | <del> 37 |     fn bar<'a, L: X<&'a Nested<Self>>>(); </del> <ins> 38 |     fn bar<'a, L: X<&'a Nested<Self>>>(); </ins> |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:37:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:38:5 </ins> | <del> 37 |     fn bar<'a, L: X<&'a Nested<Self>>>(); </del> <ins> 38 |     fn bar<'a, L: X<&'a Nested<Self>>>(); </ins> |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <ins> 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 | |     } | |_____^ </ins> error[E0309]: the parameter type `K` may not live long enough <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:43:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:51:5 </ins> | <del> 42 |   impl<K> Nested<K> { </del> <ins> 50 |   impl<K> Nested<K> { </ins> |        - help: consider adding an explicit lifetime bound `K: 'a`... <del> 43 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { 44 | |         //~^ ERROR may not live long enough 45 | |     } </del> <ins> 51 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { 52 | |         //~^ ERROR may not live long enough 53 | |     } </ins> | |_____^ | note: ...so that the reference type `&'a Nested<K>` does not outlive the data it points at <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:43:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:51:5 </ins> | <del> 43 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { 44 | |         //~^ ERROR may not live long enough 45 | |     } </del> <ins> 51 | /     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { 52 | |         //~^ ERROR may not live long enough 53 | |     } </ins> | |_____^ error[E0309]: the parameter type `M` may not live long enough <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:46:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:54:5 </ins> | <del> 46 |       fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { </del> <ins> 54 |       fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { </ins> |       ^                                                -- help: consider adding an explicit lifetime bound `M: 'a`... |  _____| | | <del> 47 | |         //~^ ERROR may not live long enough 48 | |     } </del> <ins> 55 | |         //~^ ERROR may not live long enough 56 | |     } </ins> | |_____^ | note: ...so that the reference type `&'a Nested<M>` does not outlive the data it points at <del> --> $DIR/lifetime-doesnt-live-long-enough.rs:46:5 </del> <ins> --> $DIR/lifetime-doesnt-live-long-enough.rs:54:5 </ins> | <del> 46 | /     fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { 47 | |         //~^ ERROR may not live long enough 48 | |     } </del> <ins> 54 | /     fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { 55 | |         //~^ ERROR may not live long enough 56 | |     } </ins> | |_____^ <del> error: aborting due to 6 previous errors </del> <ins> error: aborting due to 7 previous errors </ins>