Skip to content

lifetime order breaks member constraints #104639

@aliemjay

Description

@aliemjay

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: lXMdKPzIUUNTRnjy

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

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions