Open
Description
openedon Sep 30, 2021
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
Related (purely diagnostics) PR: #89327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)Area: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.