1 // check that static methods don't get to assume their trait-ref
3 // FIXME(#27579): this is just a bug. However, our checking with
4 // static inherent methods isn't quite working - need to
5 // fix that before removing the check.
7 trait Foo<'a, 'b, T>: Sized {
8 fn make_me() -> Self { loop {} }
9 fn static_evil(u: &'b u32) -> &'a u32;
12 struct Evil<'a, 'b: 'a>(Option<&'a &'b ()>);
14 impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () {
15 fn make_me() -> Self { }
16 fn static_evil(u: &'b u32) -> &'a u32 {
18 //~^ ERROR lifetime may not live long enough
22 struct IndirectEvil<'a, 'b: 'a>(Option<&'a &'b ()>);
24 impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> {
25 fn make_me() -> Self { IndirectEvil(None) }
26 fn static_evil(u: &'b u32) -> &'a u32 {
27 let me = Self::make_me();
28 //~^ ERROR lifetime may not live long enough
29 loop {} // (`me` could be used for the lifetime transmute).
33 impl<'a, 'b> Evil<'a, 'b> {
34 fn inherent_evil(u: &'b u32) -> &'a u32 {
36 //~^ ERROR lifetime may not live long enough
40 // while static methods don't get to *assume* this, we still
41 // *check* that they hold.
43 fn evil<'a, 'b>(b: &'b u32) -> &'a u32 {
45 //~^ ERROR lifetime may not live long enough
48 fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 {
49 <IndirectEvil>::static_evil(b)
50 //~^ ERROR lifetime may not live long enough
53 fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 {
54 <Evil>::inherent_evil(b)
55 //~^ ERROR lifetime may not live long enough