-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Rename, clarify, and document code for "erasing" query values #151565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
| /// 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. )
This comment has been minimized.
This comment has been minimized.
|
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. |
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:
erase→erase_val(avoiding ambiguity with moduleerase)restore→restore_valErase<T>→Erased<T>(for actual erased values ofT)EraseType→Erasable(for types that can be erased and restored)EraseType::Result→Erasable::StorageErased<T>→ErasedData<Storage>There should be no change to compiler behaviour.