Skip to content

Commit 748af6b

Browse files
authoredFeb 25, 2025
Rollup merge of rust-lang#136522 - compiler-errors:dyn_compatible_for_dispatch, r=oli-obk
Remove `feature(dyn_compatible_for_dispatch)` from the compiler This PR proposes the removal of `feature(dyn_compatible_for_dispatch)` from the compiler. * As far as I can tell from the tracking issue, there's very little demand for this feature. I think that if this feature becomes useful in the future, then a fresh implementation from a fresh set of eyes, with renewed understanding of how this feature fits into the picture of Rust as it exists **today** would be great to have; however, in the absence of this demand, I don't see a particularly good reason to keep this implementation around. * The RFC didn't receive very much discussion outside of the lang team, and while the discussion it received seemed to suggest that this feature was aiming to simplify the language and improve expressibility, I don't think this feature has really demonstrated either of those goals in practice. Furthermore, nobody seems to have owned this feature for quite some time or express desire to push for its stabilization. * Relatedly, I find some of the RFC discussion like "when we make things impossible it's often presumptuous"[^1] and "I tend to want to take a 'we are all adults here' attitude toward unsafe code"[^2] to be particularly uncompelling. Of course this is no criticism to the authors of those comments since they're pretty old comments now, but type soundness is (IMO) the primary goal of the types team. This feature doesn't really do much other than further complicating the story of where we must validate object safety for soundness, along making dyn-incompatible trait object types *almost* seem useful, but very much remain UB to create and misleading to users who don't know better. * Dyn compatibility's story has gotten more complicated since the feature was proposed in 2017, and now it needs to interact with things like associated consts, GATs, RPITITs, trait upcasting, `dyn*`, etc. While some of this is exercised in the codebase today, I'm not confident all of the corners of this feature have been hammered out. Reducing the "surface area" for what can go wrong in the compiler, especially around a side of the language (`dyn Trait`) that has been known to be particularly unsound in the past, seems good enough motivation to get rid of this for now. [^1]: rust-lang/rfcs#2027 (comment) [^2]: rust-lang/rfcs#2027 (comment) cc `@rust-lang/types` `@rust-lang/lang` Tracking: - rust-lang#43561 r? types
2 parents 617aad8 + f3d31f7 commit 748af6b

File tree

58 files changed

+511
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+511
-886
lines changed
 

‎compiler/rustc_feature/src/removed.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ declare_features! (
100100
Some("renamed to `doc_notable_trait`")),
101101
/// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
102102
(removed, dropck_parametricity, "1.38.0", Some(28498), None),
103+
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible[^1].
104+
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
105+
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
106+
///
107+
/// Renamed from `object_safe_for_dispatch`.
108+
///
109+
/// [^1]: Formerly known as "object safe".
110+
(removed, dyn_compatible_for_dispatch, "1.83.0", Some(43561),
111+
Some("removed, not used heavily and represented additional complexity in dyn compatibility")),
103112
/// Uses generic effect parameters for ~const bounds
104113
(removed, effects, "1.84.0", Some(102090),
105114
Some("removed, redundant with `#![feature(const_trait_impl)]`")),

‎compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,6 @@ declare_features! (
270270
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
271271
/// Allows using the `may_dangle` attribute (RFC 1327).
272272
(unstable, dropck_eyepatch, "1.10.0", Some(34761)),
273-
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible[^1].
274-
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
275-
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
276-
///
277-
/// Renamed from `object_safe_for_dispatch`.
278-
///
279-
/// [^1]: Formerly known as "object safe".
280-
(unstable, dyn_compatible_for_dispatch, "1.83.0", Some(43561)),
281273
/// Allows using the `#[fundamental]` attribute.
282274
(unstable, fundamental, "1.0.0", Some(29635)),
283275
/// Allows using `#[link_name="llvm.*"]`.

0 commit comments

Comments
 (0)
Please sign in to comment.