Skip to content

Eliminate QueryLatchInfo.#153689

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-QueryLatchInfo
Mar 11, 2026
Merged

Eliminate QueryLatchInfo.#153689
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-QueryLatchInfo

Conversation

@nnethercote
Copy link
Contributor

The boolean complete flag indicates whether the waiters vec is still in use, which means the waiters vec must be empty when complete is true. This is achieved by using drain on the waiters just after complete is set.

We can do better by using the type system to make invalid combinations impossible. This commit removes complete and puts the waiters inside an Option. Some means the query job is still active, and None once it is complete. And QueryLatchInfo is eliminated.

(The Arc<Mutex<Option<Vec<Arc<QueryWaiter<'tcx>>>>>> type is a mouthful, but when it's all in one place I find it easier to understand than when it's split across two types. And we can use Option methods like as_ref, as_mut, and take, which is nice.)

r? @petrochenkov

The boolean `complete` flag indicates whether the `waiters` vec is still
in use, which means the `waiters` vec must be empty when `complete` is
true. This is achieved by using `drain` on the waiters just after
`complete` is set.

We can do better by using the type system to make invalid combinations
impossible. This commit removes `complete` and puts the waiters inside
an `Option`. `Some` means the query job is still active, and `None` once
it is complete. And `QueryLatchInfo` is eliminated.

(The `Arc<Mutex<Option<Vec<Arc<QueryWaiter<'tcx>>>>>>` type is a
mouthful, but when it's all in one place I find it easier to understand
than when it's split across two types. And we can use `Option` methods
like `as_ref`, `as_mut`, and `take`, which is nice.)
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Mar 11, 2026
@nnethercote
Copy link
Contributor Author

This is a follow-up to #153595.

cc @zetanumbers @Zoxc

@petrochenkov
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 11, 2026

📌 Commit 3a558f6 has been approved by petrochenkov

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 Mar 11, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #153072 (Allow merging all libcore/alloc doctests into a single binary)
 - #153408 (miri: make read_discriminant UB when the tag is not in the validity range of the tag field)
 - #153674 (Detect inherent method behind deref being shadowed by trait method)
 - #153689 (Eliminate `QueryLatchInfo`.)
@rust-bors rust-bors bot merged commit 53e67f2 into rust-lang:main Mar 11, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 11, 2026
@nnethercote nnethercote deleted the rm-QueryLatchInfo branch March 11, 2026 21:18
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Mar 12, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#153072 (Allow merging all libcore/alloc doctests into a single binary)
 - rust-lang/rust#153408 (miri: make read_discriminant UB when the tag is not in the validity range of the tag field)
 - rust-lang/rust#153674 (Detect inherent method behind deref being shadowed by trait method)
 - rust-lang/rust#153689 (Eliminate `QueryLatchInfo`.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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