Skip to content

Commit

Permalink
Merge pull request #1435 from kpreid/patch-1
Browse files Browse the repository at this point in the history
Document object unsafety of async-fn-in-trait
  • Loading branch information
ehuss authored Dec 10, 2023
2 parents 692d216 + 46ed38d commit f9f5b5b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/items/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Object safe traits can be the base trait of a [trait object]. A trait is
* It must not have any associated constants.
* It must not have any associated types with generics.
* All associated functions must either be dispatchable from a trait object or be explicitly non-dispatchable:
* Dispatchable functions require:
* Not have any type parameters (although lifetime parameters are allowed),
* Dispatchable functions must:
* Not have any type parameters (although lifetime parameters are allowed).
* Be a [method] that does not use `Self` except in the type of the receiver.
* Have a receiver with one of the following types:
* `&Self` (i.e. `&self`)
Expand All @@ -82,7 +82,10 @@ Object safe traits can be the base trait of a [trait object]. A trait is
* [`Rc<Self>`]
* [`Arc<Self>`]
* [`Pin<P>`] where `P` is one of the types above
* Does not have a `where Self: Sized` bound (receiver type of `Self` (i.e. `self`) implies this).
* Not have an opaque return type; that is,
* Not be an `async fn` (which has a hidden `Future` type).
* Not have a return position `impl Trait` type (`fn example(&self) -> impl Trait`).
* Not have a `where Self: Sized` bound (receiver type of `Self` (i.e. `self`) implies this).
* Explicitly non-dispatchable functions require:
* Have a `where Self: Sized` bound (receiver type of `Self` (i.e. `self`) implies this).

Expand Down

0 comments on commit f9f5b5b

Please sign in to comment.