// check-pass use std::marker::PhantomData; pub struct Id<'id>(PhantomData &'id ()>); fn new_id() -> Id<'static> { Id(PhantomData) } pub trait HasLifetime where { type AtLifetime<'a>; } pub struct ExistentialLifetime(S::AtLifetime<'static>); impl ExistentialLifetime { pub fn new(f: F) -> ExistentialLifetime where for<'id> F: FnOnce(Id<'id>) -> S::AtLifetime<'id> { ExistentialLifetime(f(new_id())) } } struct ExampleS<'id>(Id<'id>); struct ExampleMarker; impl HasLifetime for ExampleMarker { type AtLifetime<'id> = ExampleS<'id>; } fn broken0() -> ExistentialLifetime { fn new_helper<'id>(id: Id<'id>) -> ExampleS<'id> { ExampleS(id) } ExistentialLifetime::::new(new_helper) } fn broken1() -> ExistentialLifetime { fn new_helper<'id>(id: Id<'id>) -> ::AtLifetime<'id> { ExampleS(id) } ExistentialLifetime::::new(new_helper) } fn broken2() -> ExistentialLifetime { ExistentialLifetime::::new(|id| ExampleS(id)) } fn main() {}