Description
The following code should pass regardless of the declaration order of lifetimes: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=88e227f9f7a5b516bffe21e09b18cd5e
async fn fail<'a, 'b, 'c>(_: &'static str) where 'a: 'c, 'b: 'c, {}
async fn pass<'a, 'c, 'b>(_: &'static str) where 'a: 'c, 'b: 'c, {}
This is related to #63033 but it's different in that we do have a lower bound region, 'c
, but we fail to recognize that because the algorithm here, which is responsible for calculating min_choice
from choice_regions = ['static, 'a, 'b, 'c]
, assumes that the outlive relation is a total order, which is not true.
Here is the graph of self.universal_region_relations
:
So we need an efficient algorithm that works for partial order relations, but the one that comes to mind is O(n^2)
. The perf may not be really important here but I'm curious to see the alternatives.
@rustbot label C-bug T-compiler A-borrow-checker E-mentor E-help-wanted