Skip to content

Conversation

@dingxiangfei2009
Copy link
Contributor

@dingxiangfei2009 dingxiangfei2009 commented Dec 14, 2025

This does not fix #148727, rather probably a good addition to how Unsize behaves. I am looking into anti-fundamenetal trait as suggested to solve a different problem.

This patch proposes relaxation on the type unsizing condition.
PhantomData has been in the current type system exempted from being treated as carrying any data, including dropck, virtual call dispatch by DispatchFromDyn and unsizing container by CoerceUnsize. PhantomData is a special 1-ZST that really carries no "data" of the types it captures.

I propose that we should also extend this interpretation to Unsize.

This patch proposes relaxation on the type unsizing
condition.
`PhantomData` has been in the current type system
exempted from being treated as carrying any data,
including dropck, virtual call dispatch by
`DispatchFromDyn` and unsizing container by
`CoerceUnsize`.
`PhantomData` is a special 1-ZST that really
carries no "data" of the types it captures.

I propose that we should also extend this
interpretation to `Unsize`.

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 14, 2025

r? @lcnr

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

@theemathas theemathas added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Dec 14, 2025
@theemathas
Copy link
Contributor

FYI, with the way you currently worded this PR, if it were to be merged, #148727 would be closed.

@theemathas
Copy link
Contributor

This change is visible on stable. The following code fails to compile on nightly, but compiles with this PR

use std::marker::PhantomData;

pub struct Thing<T: ?Sized>(PhantomData<T>, T);

pub fn foo(x: &Thing<i32>) -> &Thing<dyn Send> {
    x
}

I'm unsure whether this code starting to compiling might cause some library to become unsound.

@theemathas theemathas added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. 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. T-libs Relevant to the library 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 this pull request may close these issues.

Unsoundness and ICE due to DispatchFromDyn allowing bogus impls on references.

4 participants