From c775de4beee585977a78a6c647e89b4859f46018 Mon Sep 17 00:00:00 2001 From: "Tim (Theemathas) Chirananthavat" Date: Tue, 31 Mar 2026 11:29:40 +0700 Subject: [PATCH] Make `DerefPure` dyn-incompatible Fixes https://github.com/rust-lang/rust/issues/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. --- library/core/src/ops/deref.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs index 305861ea7b69..e46204c6246a 100644 --- a/library/core/src/ops/deref.rs +++ b/library/core/src/ops/deref.rs @@ -293,6 +293,7 @@ fn deref_mut(&mut self) -> &mut T { /// unchanged. #[unstable(feature = "deref_pure_trait", issue = "87121")] #[lang = "deref_pure"] +#[rustc_dyn_incompatible_trait] pub unsafe trait DerefPure: PointeeSized {} #[unstable(feature = "deref_pure_trait", issue = "87121")]