Skip to content

Commit 2e7a52b

Browse files
committed
Rename feature object_safe_for_dispatch to dyn_compatible_for_dispatch
1 parent 62b24ea commit 2e7a52b

File tree

42 files changed

+130
-124
lines changed

Some content is hidden

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

42 files changed

+130
-124
lines changed

compiler/rustc_feature/src/removed.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ declare_features! (
154154
/// then removed. But there was no utility storing it separately, so now
155155
/// it's in this list.
156156
(removed, no_stack_check, "1.0.0", None, None),
157+
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible (object safe).
158+
/// Renamed to `dyn_compatible_for_dispatch`.
159+
(removed, object_safe_for_dispatch, "CURRENT_RUSTC_VERSION", Some(43561),
160+
Some("renamed to `dyn_compatible_for_dispatch`")),
157161
/// Allows using `#[on_unimplemented(..)]` on traits.
158162
/// (Moved to `rustc_attrs`.)
159163
(removed, on_unimplemented, "1.40.0", None, None),

compiler/rustc_feature/src/unstable.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ declare_features! (
259259
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
260260
/// Allows using the `may_dangle` attribute (RFC 1327).
261261
(unstable, dropck_eyepatch, "1.10.0", Some(34761)),
262+
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
263+
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
264+
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
265+
///
266+
/// Renamed from `object_safe_for_dispatch`.
267+
///
268+
/// [^1]: Formerly known as "object safe".
269+
(unstable, dyn_compatible_for_dispatch, "CURRENT_RUSTC_VERSION", Some(43561)),
262270
/// Allows using the `#[fundamental]` attribute.
263271
(unstable, fundamental, "1.0.0", Some(29635)),
264272
/// Allows using `#[link_name="llvm.*"]`.
@@ -544,13 +552,6 @@ declare_features! (
544552
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
545553
/// Allows `for<T>` binders in where-clauses
546554
(incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
547-
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
548-
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
549-
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
550-
///
551-
/// [^1]: Formerly known as "object safe".
552-
// FIXME(dyn_compat_renaming): Rename feature.
553-
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
554555
/// Allows using enums in offset_of!
555556
(unstable, offset_of_enum, "1.75.0", Some(120141)),
556557
/// Allows using fields with slice type in offset_of!

compiler/rustc_hir_analysis/src/coherence/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn check_object_overlap<'tcx>(
199199
for component_def_id in component_def_ids {
200200
if !tcx.is_dyn_compatible(component_def_id) {
201201
// FIXME(dyn_compat_renaming): Rename test and update comment.
202-
// Without the 'object_safe_for_dispatch' feature this is an error
202+
// Without the 'dyn_compatible_for_dispatch' feature this is an error
203203
// which will be reported by wfcheck. Ignore it here.
204204
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
205205
// With the feature enabled, the trait is not implemented automatically,

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ symbols! {
776776
dropck_eyepatch,
777777
dropck_parametricity,
778778
dylib,
779+
dyn_compatible_for_dispatch,
779780
dyn_metadata,
780781
dyn_star,
781782
dyn_trait,

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ fn object_ty_for_trait<'tcx>(
639639
/// contained by the trait object, because the object that needs to be coerced is behind
640640
/// a pointer.
641641
///
642-
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result
643-
/// in a new check that `Trait` is dyn-compatible, creating a cycle (until object_safe_for_dispatch
642+
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result in
643+
/// a new check that `Trait` is dyn-compatible, creating a cycle (until dyn_compatible_for_dispatch
644644
/// is stabilized, see tracking issue <https://github.com/rust-lang/rust/issues/43561>).
645645
/// Instead, we fudge a little by introducing a new type parameter `U` such that
646646
/// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.
@@ -674,7 +674,7 @@ fn receiver_is_dispatchable<'tcx>(
674674

675675
// the type `U` in the query
676676
// use a bogus type parameter to mimic a forall(U) query using u32::MAX for now.
677-
// FIXME(mikeyhew) this is a total hack. Once object_safe_for_dispatch is stabilized, we can
677+
// FIXME(mikeyhew) this is a total hack. Once dyn_compatible_for_dispatch is stabilized, we can
678678
// replace this with `dyn Trait`
679679
let unsized_self_ty: Ty<'tcx> =
680680
Ty::new_param(tcx, u32::MAX, Symbol::intern("RustaceansAreAwesome"));

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
881881
}
882882

883883
if let Some(principal) = data.principal() {
884-
if !self.infcx.tcx.features().object_safe_for_dispatch {
884+
if !self.infcx.tcx.features().dyn_compatible_for_dispatch {
885885
principal.with_self_ty(self.tcx(), self_ty)
886886
} else if self.tcx().is_dyn_compatible(principal.def_id()) {
887887
principal.with_self_ty(self.tcx(), self_ty)

compiler/rustc_trait_selection/src/traits/wf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
829829
// obligations that don't refer to Self and
830830
// checking those
831831

832-
let defer_to_coercion = tcx.features().object_safe_for_dispatch;
832+
let defer_to_coercion = tcx.features().dyn_compatible_for_dispatch;
833833

834834
if !defer_to_coercion {
835835
if let Some(principal) = data.principal_def_id() {

tests/crashes/120241-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ known-bug: #120241
22
//@ edition:2021
3-
#![feature(object_safe_for_dispatch)]
3+
#![feature(dyn_compatible_for_dispatch)]
44
#![feature(unsized_fn_params)]
55

66
fn guard(_s: Copy) -> bool {

tests/crashes/120241.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ known-bug: #120241
22
//@ edition:2021
3-
#![feature(object_safe_for_dispatch)]
3+
#![feature(dyn_compatible_for_dispatch)]
44

55
trait B {
66
fn f(a: A) -> A;

tests/crashes/120482.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ known-bug: #120482
22
//@ edition:2021
3-
#![feature(object_safe_for_dispatch)]
3+
#![feature(dyn_compatible_for_dispatch)]
44

55
trait B {
66
fn bar(&self, x: &Self);

0 commit comments

Comments
 (0)