Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Enselic:best-blame-index
Jul 13, 2026
Merged

borrowck: Represent 'best blame constraint' as index into Vec<OutlivesConstraint>#159201
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Enselic:best-blame-index

Conversation

@Enselic

@Enselic Enselic commented Jul 13, 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 simplification while investigating ways to solve #138408.

(See #158623 for the preparations for this commit.)

…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.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 13, 2026
@rustbot

rustbot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: borrowck, compiler
  • borrowck, compiler expanded to 75 candidates
  • Random selection from 20 candidates

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this does read better IMO
@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9a3aed4 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 13, 2026
Rollup of 11 pull requests

Successful merges:

 - #159210 (`rust-analyzer` subtree update)
 - #158655 (Fix coroutine MIR saved local remapping)
 - #159205 (bootstrap: Replace `ShouldRun::crates` with `crate_or_deps_filtered`)
 - #159208 (Fix `attr_on_non_tail_expr` typo)
 - #157524 (Fix relative paths in private import suggestions)
 - #158325 (Document NonNull layout guarantees)
 - #158882 (enable `do_not_recommend` attr for method call errors in current solver)
 - #158982 (Pretty-print MIR user types too.)
 - #159069 (Add codegen test for constant returns after local use)
 - #159163 (rustc_target: Add acquire-release to implied features of v8)
 - #159201 (borrowck: Represent 'best blame constraint' as index into `Vec<OutlivesConstraint>`)
rust-bors Bot pushed a commit that referenced this pull request Jul 13, 2026
Rollup of 11 pull requests

Successful merges:

 - #159210 (`rust-analyzer` subtree update)
 - #158655 (Fix coroutine MIR saved local remapping)
 - #159205 (bootstrap: Replace `ShouldRun::crates` with `crate_or_deps_filtered`)
 - #159208 (Fix `attr_on_non_tail_expr` typo)
 - #157524 (Fix relative paths in private import suggestions)
 - #158325 (Document NonNull layout guarantees)
 - #158882 (enable `do_not_recommend` attr for method call errors in current solver)
 - #158982 (Pretty-print MIR user types too.)
 - #159069 (Add codegen test for constant returns after local use)
 - #159163 (rustc_target: Add acquire-release to implied features of v8)
 - #159201 (borrowck: Represent 'best blame constraint' as index into `Vec<OutlivesConstraint>`)
@rust-bors rust-bors Bot merged commit fc4cd8e into rust-lang:main Jul 13, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 13, 2026
rust-timer added a commit that referenced this pull request Jul 13, 2026
Rollup merge of #159201 - Enselic:best-blame-index, r=jieyouxu

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

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 simplification while investigating ways to solve #138408.

(See #158623 for the preparations for this commit.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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