Skip to content
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

DispatchFromDyn builtin checks are weaker than CoerceUnsized #135215

Open
BoxyUwU opened this issue Jan 7, 2025 · 5 comments · May be fixed by #135228
Open

DispatchFromDyn builtin checks are weaker than CoerceUnsized #135215

BoxyUwU opened this issue Jan 7, 2025 · 5 comments · May be fixed by #135228
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions F-derive_coerce_pointee Feature: RFC 3621's oft-renamed implementation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 7, 2025

DispatchFromDyn doesn't require the type parameter to only be used in one field and potentially phantomdata, instead it requires one field and arbitarily many ZSTs playground. This in theory means that dispatch from dyn impls can result in effectively arbitrary transmutes from MyZST<dyn Trait> to MyZST<Foo>.

In practice I don't think this is exploitable, regardless I don't think we should stabilize the ability for semi-user-written impls or trait bounds to be written involving this trait until the builtin checks are brought in line with CoerceUnsized.

edit: thanks to @steffahn for pointing this out

@rfcbot concern DispatchFromDyn builtin checks are weaker than CoerceUnsized

Originally posted by @BoxyUwU in #133820 (comment)

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2025
@BoxyUwU BoxyUwU added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-coercions Area: implicit and explicit `expr as Type` coercions T-types Relevant to the types team, which will review and decide on the PR/issue. F-derive_coerce_pointee Feature: RFC 3621's oft-renamed implementation and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 7, 2025
@steffahn
Copy link
Member

steffahn commented Jan 7, 2025

I think actually @Darksonn noticed this issue.

It's definitely an issue for dispatch-from-dyn as a feature. Is this the right place to track that, or is this specific to the issue only as far as it is relevant for CoercePointee?

@steffahn

This comment has been minimized.

@Darksonn
Copy link
Contributor

Darksonn commented Jan 7, 2025

Is this really a concern for derive(CoercePointee)? The macro also emits a CoerceUnsize implementation, which comes with the PhantomData validation that is needed to fix this.

@workingjubilee workingjubilee changed the title concern DispatchFromDyn builtin checks are weaker than CoerceUnsized DispatchFromDyn builtin checks are weaker than CoerceUnsized Jan 7, 2025
@steffahn
Copy link
Member

steffahn commented Jan 7, 2025

I think it makes sense to track the question of “how much should this be fixed before CoercePointee-stabilization” separately from the issue itself, so I opened #135220

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Jan 7, 2025

tbc this issue is supposed to track the bug itself more so than the actual concern for the stabilization PR. I just didn't bother to write out a proper issue description because i was in a hurry :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions F-derive_coerce_pointee Feature: RFC 3621's oft-renamed implementation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants