Skip to content

Commit 62b24ea

Browse files
committed
Compiler: Replace remaining occurrences of "object safe" with "dyn compatible"
1 parent 9c7013c commit 62b24ea

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
//! "Object safety" refers to the ability for a trait to be converted
2-
//! to an object. In general, traits may only be converted to an
3-
//! object if all of their methods meet certain criteria. In particular,
4-
//! they must:
1+
//! "Dyn-compatibility"[^1] refers to the ability for a trait to be converted
2+
//! to a trait object. In general, traits may only be converted to a trait
3+
//! object if certain criteria are met.
54
//!
6-
//! - have a suitable receiver from which we can extract a vtable and coerce to a "thin" version
7-
//! that doesn't contain the vtable;
8-
//! - not reference the erased type `Self` except for in this receiver;
9-
//! - not have generic type parameters.
5+
//! [^1]: Formerly known as "object safety".
106
117
use std::iter;
128
use std::ops::ControlFlow;
@@ -506,8 +502,8 @@ fn virtual_call_violations_for_method<'tcx>(
506502

507503
/// This code checks that `receiver_is_dispatchable` is correctly implemented.
508504
///
509-
/// This check is outlined from the object safety check to avoid cycles with
510-
/// layout computation, which relies on knowing whether methods are object safe.
505+
/// This check is outlined from the dyn-compatibility check to avoid cycles with
506+
/// layout computation, which relies on knowing whether methods are dyn-compatible.
511507
fn check_receiver_correct<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, method: ty::AssocItem) {
512508
if !is_vtable_safe_method(tcx, trait_def_id, method) {
513509
return;
@@ -644,7 +640,7 @@ fn object_ty_for_trait<'tcx>(
644640
/// a pointer.
645641
///
646642
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result
647-
/// in a new check that `Trait` is object safe, creating a cycle (until object_safe_for_dispatch
643+
/// in a new check that `Trait` is dyn-compatible, creating a cycle (until object_safe_for_dispatch
648644
/// is stabilized, see tracking issue <https://github.com/rust-lang/rust/issues/43561>).
649645
/// Instead, we fudge a little by introducing a new type parameter `U` such that
650646
/// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.
@@ -865,7 +861,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
865861
}
866862

867863
fn visit_const(&mut self, ct: ty::Const<'tcx>) -> Self::Result {
868-
// Constants can only influence object safety if they are generic and reference `Self`.
864+
// Constants can only influence dyn-compatibility if they are generic and reference `Self`.
869865
// This is only possible for unevaluated constants, so we walk these here.
870866
self.tcx.expand_abstract_consts(ct).super_visit_with(self)
871867
}

0 commit comments

Comments
 (0)