TLDR: The following does not compile but it should
trait Trait<'a, 'b> {}
impl<T> Trait<'_, '_> for T {}
struct Struct<'a>(&'a u8);
fn foo<'a, 'b>(a: Struct<'a>, b: Struct<'b>) -> impl Trait<'a, 'b> {
if false { a } else { b }
}
The lifetime of the if false { a } else { b } is 'a OR 'b, but right now we can only express 'a AND 'b (as 'lifetime: 'a + 'b).
Beyond diagnostics, only impl trait can actually encounter such lifetimes in a somewhat reasonable way.
So the plan is as follows:
- add intersection lifetimes to mir borrowck, without actually creating them
- specifically create them for member constraints that would otherwise be unresolvable
- put a lot of effort into making the diagnostics comprehensible
Some details: https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/member.20constraints.20PR.20.2389056/near/255496552
Related (purely diagnostics) PR: #89327
TLDR: The following does not compile but it should
The lifetime of the
if false { a } else { b }is'aOR'b, but right now we can only express'aAND'b(as'lifetime: 'a + 'b).Beyond diagnostics, only impl trait can actually encounter such lifetimes in a somewhat reasonable way.
So the plan is as follows:
Some details: https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/member.20constraints.20PR.20.2389056/near/255496552
Related (purely diagnostics) PR: #89327