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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants