Skip to content

Conversation

@Zalathar
Copy link
Member

@Zalathar Zalathar commented Jan 24, 2026

In order to reduce compile times and code size for the compiler itself, the query system has a mechanism for “erasing” and ”restoring” query values in certain contexts. See #109333 for the original implementation.

Unfortunately, the erasure system has very little documentation, and involves a dizzying assortment of similarly-named types, traits, and functions.

This PR therefore renames several parts of the erasure API and implementation to hopefully be clearer, and adds comments to better explain the purpose and mechanism behind value erasure.

Summary of renames:

  • fn eraseerase_val (avoiding ambiguity with module erase)
  • fn restorerestore_val
  • type Erase<T>Erased<T> (for actual erased values of T)
  • trait EraseTypeErasable (for types that can be erased and restored)
  • associated type EraseType::ResultErasable::Storage
  • implementation-detail struct Erased<T>ErasedData<Storage>

There should be no change to compiler behaviour.

@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 Jan 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2026

r? @SparrowLii

rustbot has assigned @SparrowLii.
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

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@petrochenkov
Copy link
Contributor

r? @petrochenkov

@rustbot rustbot assigned petrochenkov and unassigned SparrowLii Jan 26, 2026
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 26, 2026
Copy link
Contributor

@zetanumbers zetanumbers left a comment

Choose a reason for hiding this comment

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

I don't find these changes to be useful or clarifying.

View changes since this review

@rustbot

This comment has been minimized.

@Zalathar
Copy link
Member Author

Addressed some feedback and added a few more comments and FIXMEs (diff)

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@Zalathar
Copy link
Member Author

@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 Jan 29, 2026
@rustbot rustbot added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jan 29, 2026
@rust-bors

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 29, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Zalathar
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jan 29, 2026
@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 29, 2026

📌 Commit db74048 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 Jan 29, 2026
rust-bors bot pushed a commit that referenced this pull request Jan 29, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #147387 (hir_owner_parent optimized to inlined call for non-incremental build)
 - #150271 (Move struct placeholder pt2)
 - #151283 (Suggest ignore returning value inside macro for unused_must_use lint)
 - #151565 (Rename, clarify, and document code for "erasing" query values)
 - #149482 (thread::scope: document how join interacts with TLS destructors)
 - #151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
 - #151833 (Treat unions as 'data types' in attr parsing diagnostics)
 - #151834 (Update `askama` version to `0.15.4`)
@rust-bors rust-bors bot merged commit 3991cf6 into rust-lang:main Jan 29, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 29, 2026
rust-timer added a commit that referenced this pull request Jan 29, 2026
Rollup merge of #151565 - Zalathar:erase, r=petrochenkov

Rename, clarify, and document code for "erasing" query values

In order to reduce compile times and code size for the compiler itself, the query system has a mechanism for “erasing” and ”restoring” query values in certain contexts. See #109333 for the original implementation.

Unfortunately, the erasure system has very little documentation, and involves a dizzying assortment of similarly-named types, traits, and functions.

This PR therefore renames several parts of the erasure API and implementation to hopefully be clearer, and adds comments to better explain the purpose and mechanism behind value erasure.

Summary of renames:
- fn `erase` → `erase_val` (avoiding ambiguity with module `erase`)
- fn `restore` → `restore_val`
- type `Erase<T>` → `Erased<T>` (for actual erased values of `T`)
- trait `EraseType` → `Erasable` (for types that can be erased and restored)
- associated type `EraseType::Result` → `Erasable::Storage`
- implementation-detail struct `Erased<T>` → `ErasedData<Storage>`

There should be no change to compiler behaviour.
@Zalathar Zalathar deleted the erase branch January 29, 2026 22:45
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.

9 participants