1 #![feature(type_alias_impl_trait)]
3 type WithLifetime<'a> = impl Equals<SelfType = ()>;
4 fn _defining_use<'a>() -> WithLifetime<'a> {}
8 fn convert<'b, T: ?Sized>(_proof: &'b Self::Witness, x: &'a T) -> &'b T;
11 impl<'a> Convert<'a> for () {
12 type Witness = WithLifetime<'a>;
14 fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<'a>, x: &'a T) -> &'b T {
15 // compiler used to think it gets to assume 'a: 'b here because
16 // of the `&'b WithLifetime<'a>` argument
18 //~^ ERROR lifetime may not live long enough
22 fn extend_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
23 WithLifetime::<'a>::convert_helper::<(), T>(&(), x)
28 fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
29 proof: &'b Self::SelfType,
34 impl<S> Equals for S {
36 fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
47 let x = String::from("Hello World?");
48 r = extend_lifetime(&x);