Skip to content

borrowck: Represent 'best blame constraint' as index into Vec<OutlivesConstraint>#158623

Draft
Enselic wants to merge 4 commits into
rust-lang:mainfrom
Enselic:best-blame
Draft

borrowck: Represent 'best blame constraint' as index into Vec<OutlivesConstraint>#158623
Enselic wants to merge 4 commits into
rust-lang:mainfrom
Enselic:best-blame

Conversation

@Enselic

@Enselic Enselic commented Jun 30, 2026

Copy link
Copy Markdown
Member

This makes the code simpler and easier to understand, since we don't have to partially copy an OutlivesConstraint into the BlameConstraint struct (which we can remove entirely) and the BorrowExplanation::MustBeValidFor enum variant (which we can simplify).

Instead, we reference the "best" OutlivesConstraint by an index into Vec<OutlivesConstraint>. This is not only simpler, it also opens up the possibility for diagnostics to access the full OutlivesConstraint info.

I discovered this cleanup while investigating ways to solve #138408.

Draft

This PR is not ready for review. I will split this up into smaller PRs for easier review. The purpose of this PR is to:

  • See if CI pass.
  • Illustrate where the smaller PRs will take us.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 30, 2026
@Enselic Enselic added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Jun 30, 2026
@rust-log-analyzer

This comment has been minimized.

@Enselic Enselic closed this Jun 30, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 30, 2026
@Enselic Enselic reopened this Jun 30, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 30, 2026
@rust-log-analyzer

This comment has been minimized.

Enselic added 4 commits June 30, 2026 23:58
…g new one

So that we in an upcoming commit can return the index into path instead
of a "duplicate".

This passes:

    ./x test --bless tests/ui --keep-stage-std 1 --set rust.deny-warnings=false
…esConstraint>`

This makes the code simpler and easier to understand, since we don't
have to partially copy an `OutlivesConstraint` into the
`BlameConstraint` struct (which we can remove entirely) and the
`BorrowExplanation::MustBeValidFor` enum variant (which we can
simplify).

Instead, we reference the "best" `OutlivesConstraint` by an index into
`Vec<OutlivesConstraint>`. This is not only simpler, it also  opens up
the possibility for diagnostics to access the full `OutlivesConstraint`
info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants