@@ -62,12 +62,12 @@ trait Seq<T> {
6262}
6363```
6464
65- ## Object Safety
65+ ## Trait- Object Safety {#object-safety}
6666
67- Object safe traits can be the base trait of a [ trait object] . A trait is
68- * object safe* if it has the following qualities (defined in [ RFC 255] ):
67+ An object- safe trait can be used in a ` dyn Trait ` type, and be the base trait of a [ trait object] .
68+ A trait is * object safe* if it has the following qualities (defined in [ RFC 255] ):
6969
70- * All [ supertraits] must also be object safe.
70+ * All [ supertraits] must also be trait- object safe.
7171* ` Sized ` must not be a [ supertrait] [ supertraits ] . In other words, it must not require ` Self: Sized ` .
7272* It must not have any associated constants.
7373* It must not have any associated types with generics.
@@ -93,7 +93,7 @@ Object safe traits can be the base trait of a [trait object]. A trait is
9393# use std :: rc :: Rc ;
9494# use std :: sync :: Arc ;
9595# use std :: pin :: Pin ;
96- // Examples of object safe methods.
96+ // Examples of trait- object safe methods.
9797trait TraitMethods {
9898 fn by_ref (self : & Self ) {}
9999 fn by_ref_mut (self : & mut Self ) {}
@@ -110,7 +110,7 @@ trait TraitMethods {
110110```
111111
112112``` rust,compile_fail
113- // This trait is object-safe, but these methods cannot be dispatched on a trait object.
113+ // This trait is object-safe, but these methods cannot be dispatched on a trait object (such as `&dyn NonDispatchable`) .
114114trait NonDispatchable {
115115 // Non-methods cannot be dispatched.
116116 fn foo() where Self: Sized {}
@@ -135,7 +135,7 @@ obj.typed(1); // ERROR: cannot call with generic type
135135``` rust,compile_fail
136136# use std::rc::Rc;
137137// Examples of non-object safe traits.
138- trait NotObjectSafe {
138+ trait NotDynCompatible {
139139 const CONST: i32 = 1; // ERROR: cannot have associated const
140140
141141 fn foo() {} // ERROR: associated function without Sized
@@ -145,14 +145,14 @@ trait NotObjectSafe {
145145}
146146
147147struct S;
148- impl NotObjectSafe for S {
148+ impl NotDynCompatible for S {
149149 fn returns(&self) -> Self { S }
150150}
151- let obj: Box<dyn NotObjectSafe > = Box::new(S); // ERROR
151+ let obj: Box<dyn NotDynCompatible > = Box::new(S); // ERROR
152152```
153153
154154``` rust,compile_fail
155- // Self: Sized traits are not object-safe.
155+ // Self: Sized traits are not trait- object-safe.
156156trait TraitWithSize where Self: Sized {}
157157
158158struct S;
@@ -161,7 +161,7 @@ let obj: Box<dyn TraitWithSize> = Box::new(S); // ERROR
161161```
162162
163163``` rust,compile_fail
164- // Not object safe if `Self` is a type argument.
164+ // Not trait- object safe if `Self` is a type argument.
165165trait Super<A> {}
166166trait WithSelf: Super<Self> where Self: Sized {}
167167
@@ -326,7 +326,7 @@ fn main() {
326326[ _Visibility_ ] : ../visibility-and-privacy.md
327327[ _WhereClause_ ] : generics.md#where-clauses
328328[ bounds ] : ../trait-bounds.md
329- [ trait object ] : ../types/trait-object.md
329+ [ trait objects ] : ../types/trait-object.md
330330[ RFC 255 ] : https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
331331[ associated items ] : associated-items.md
332332[ method ] : associated-items.md#methods
0 commit comments