Skip to content

Overhaul Erasable impls#154351

Open
nnethercote wants to merge 7 commits intorust-lang:mainfrom
nnethercote:overhaul-Erasable-impls
Open

Overhaul Erasable impls#154351
nnethercote wants to merge 7 commits intorust-lang:mainfrom
nnethercote:overhaul-Erasable-impls

Conversation

@nnethercote
Copy link
Contributor

This PR removes many unused Erasable impls, converts many of the hand-written impls to macro-generated impls, and sorts the macro's inputs. This cuts over 200 lines of code and fixes three FIXME comments.

r? @petrochenkov

It's imported and can be used directly within this file, and already is
in a few places.
A few can be done with the `impl_erasable_for_single_lifetime_types!`
macro instead of being hand-written.
Using '_ removes unnecessary differences between the impl type and the
associated `Storage` type.
Now that 'static lifetimes aren't used, a lot of the hand-written
`Erasable` impls can now be done with the macro. (The only ones that
can't are those with a generic type parameter, because `size_of`
doesn't work in that case.)

Also, `impl_erasable_for_single_lifetime_types!` isn't needed at all.
Some of the hand-written `Erasable` impls only match a single type in
practice. It's easier to just list the concrete types in
`impl_erasable_for_types_with_no_type_params!`.
@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 Mar 25, 2026
@nnethercote
Copy link
Contributor Author

cc @Zoxc @Zalathar

@Zalathar
Copy link
Member

I'm surprised that replacing 'static with '_ even works, but the fact that it does is very nice here.

(My intuition is that type contexts tend to be very picky about anonymous lifetimes, but I guess that's less true of const-in-type contexts.)

@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 25, 2026

📌 Commit 4f03262 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 25, 2026
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.

4 participants