Inconsistent lifetime rules with parameter patterns #86989
Labels
A-lifetimes
Area: Lifetimes / regions
A-patterns
Relating to patterns and pattern matching
C-discussion
Category: Discussion or questions that doesn't represent real issues.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Here's an example derived from rayon-rs/rayon#866:
playground
The first two loops fail, because
x
has an "external" lifetime thatc
can't possibly satisfy. However, with the third pattern,x
gets a local lifetime which can be assigned fromc
. @nikomatsakis explained it this way:In the original issue, @evergreen-trading-systems was surprised not to get an error in the destructured case, but I don't think that's something we could (or should) go back on now. It would be more interesting if even the trivial pattern could be made to work with a reduced lifetime.
The text was updated successfully, but these errors were encountered: