Skip to content

avoid Rc/Arc eq specialization for types with dyn Trait tail - #166143

Open
RalfJung wants to merge 1 commit into
rust-lang:mainfrom
RalfJung:rc-ec-specialization
Open

RalfJung wants to merge 1 commit into
rust-lang:mainfrom
RalfJung:rc-ec-specialization

Conversation

@RalfJung

Copy link
Copy Markdown
Member

Fixes #164817
Cc @theemathas

@rustbot rustbot added A-rc Area: `Rc` and `Arc` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 18, 2026
@rustbot

rustbot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 38 candidates
  • Random selection from ChrisDenton, JohnTitor, Mark-Simulacrum, clarfonthey, maxdexh

@theemathas

Copy link
Copy Markdown
Contributor

Probably should also specialize on str, OsStr, CStr, Path?

@RalfJung
RalfJung force-pushed the rc-ec-specialization branch from 5028bb7 to 307f910 Compare November 18, 2026 09:51
@RalfJung

RalfJung commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

OsStr and Path are in std so we cannot easily add them here...

@RalfJung
RalfJung force-pushed the rc-ec-specialization branch from 307f910 to 5c9b917 Compare November 18, 2026 09:53
@theemathas

Copy link
Copy Markdown
Contributor

Can we do something like T: Pointee<Metadata: ComparableMetadata> and then implement ComparableMetadata for () and usize?

@RalfJung

RalfJung commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

That would require making Pointee a specialization-safe trait which I am not convinced is correct.
(And not just that, somehow the associated type also has to be specialization-safe?)

@RalfJung

RalfJung commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

I also have no idea how to figure out whether such a specialization actually kicks in. This was meant to be a quick fix which we can always refine later, so I cannot go down a deep rabbit hole here. Help is appreciated, if you have commit I can cherry-pick them. :)

@rust-log-analyzer

This comment has been minimized.

@RalfJung
RalfJung force-pushed the rc-ec-specialization branch from 5c9b917 to 086a3bb Compare November 18, 2026 10:20

This branch has not been deployed

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

Labels

A-rc Area: `Rc` and `Arc` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{Rc,Arc}::eq has suspicious specialization for DSTs due to vtable merging and opsem mess.

5 participants