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

/// Trait for types that can be erased into [`Erased<Self>`].
///
/// Erasing and unerasing values is performed by [`erase_val`] and [`restore_val`].
pub trait Erasable: Copy {
Copy link
Member Author

@Zalathar Zalathar Jan 24, 2026

Choose a reason for hiding this comment

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

Erasable goes against the notional convention of naming traits after verbs rather than adjectives, but in this case I find erasable so much clearer that I think it's justified.

Copy link
Member

@workingjubilee workingjubilee Jan 24, 2026

Choose a reason for hiding this comment

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

certainly can't be worse the status quo, since it wasn't Erase before. what does "EraseType" mean? "you can erase this type"? yeah it implements the trait, doesn't it?

( type Erase simply doesn't make much sense to me. )

@rust-bors

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 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.

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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants