Skip to content

Make DerefPure dyn-incompatible#154624

Open
theemathas wants to merge 1 commit intorust-lang:mainfrom
theemathas:deref-pure-dyn-incompat
Open

Make DerefPure dyn-incompatible#154624
theemathas wants to merge 1 commit intorust-lang:mainfrom
theemathas:deref-pure-dyn-incompat

Conversation

@theemathas
Copy link
Copy Markdown
Contributor

Fixes #154619.

If DerefPure were dyn-compatible, a trait object of a subtrait of DerefPure could be created by unsize-coercing an existing type that implements DerefPure. But then the trait object could have its own non-pure impl of Deref/DerefMut, which is unsound, since the trait object would implement DerefPure. Thus, we make DerefPure dyn-incompatible.

r? types

Fixes rust-lang#154619.

If `DerefPure` were dyn-compatible, a trait object of a subtrait of
`DerefPure` could be created by unsize-coercing an existing type that
implements `DerefPure`. But then the trait object could have its own
non-pure impl of `Deref`/`DerefMut`, which is unsound, since the trait
object would implement `DerefPure`. Thus, we make `DerefPure`
dyn-incompatible.
@rustbot rustbot added 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 Mar 31, 2026
@theemathas theemathas added T-lang Relevant to the language team T-types Relevant to the types team, which will review and decide on the PR/issue. labels Mar 31, 2026
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-lang Relevant to the language team 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.

deref_patterns is unsound due to dyn of subtrait of DerefPure

4 participants