Replacement question for traits with lifetime in specific types

fn main() {
    trait Trait<'c> {}

    impl<'c> Trait<'c> for &'_ i32 {}

    fn foo<'e, 'c: 'e, T: 'e + Trait<'c>>(_t: T) {}
    // foo expand: ??


What is the specific type of the foo function after compilation substiution? Where will the lifetime 'e and 'c be used in the specific type? Thank you for your reply!

rustc does not substitute lifetimes. It just checks whether lifetime constraints can be met, and does not actually provide a substitution.

Edit: for the second question, see this: Early and Late Bound Parameter Definitions

foo::<'_, '_, &'_ i32>

where every '_ is an independent lifetime inference variable (subject to the declared bounds) and foo in this case is the unnameable function declaration type.

There are many possible solutions (e.g. 'static for everything), but the compiler only need prove that a sound solution exists.


Thanks! I have previously seen early bound and late bound, but I just don't understand how each lifetime is used when dealing with multiple lifetime constraints involving traits.