From 819d8f91ae121d0217b06ddda94c0acc799eee39 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Mon, 6 Mar 2017 14:09:18 -0500 Subject: [PATCH 1/2] fix object safety section Minor updates. --- text/0000-trait-alias.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/text/0000-trait-alias.md b/text/0000-trait-alias.md index 568354cd7fb..12b95005fde 100644 --- a/text/0000-trait-alias.md +++ b/text/0000-trait-alias.md @@ -133,23 +133,27 @@ parameter declarations*. When using a trait alias as an object type, it is subject to object safety restrictions _after_ substituting the aliased traits. This means: -1. It contains an object safe trait and zero or more of these other bounds: `Send`, `Sync`, `'static` (that is, `trait Show = Display + Debug;` would not be object safe). +1. It contains an object safe trait, zero or more lifetimes, and zero or more of these other bounds: `Send`, `Sync` (that is, `trait Show = Display + Debug;` would not be object safe). 2. All the associated types of the trait need to be specified. +3. The `where` clause, if present, only contains bounds on `Self`. Some examples: ```rust trait Sink = Sync; -trait PrintableIterator = Display + Iterator; +trait ShareableIterator = Iterator + Sync; +trait PrintableIterator = Iterator + Display; trait IntIterator = Iterator; -fn foo(...) { ... } // ok -fn baz1(x: Box) { ... } // ERROR: associated type not specified -fn baz2(x: Box>) { ... } // ok -fn baz3(x: Box) { ... } // ok (*) +fn foo1(...) { ... } // ok +fn foo2>(...) { ... } // ok +fn bar1(x: Box) { ... } // ERROR: associated type not specified +fn bar2(x: Box>) { ... } // ok +fn bar3(x: Box) { ... } // ERROR: too many traits (*) +fn bar4(x: Box) { ... } // ok (*) ``` -The lines marked with `(*)` require [#24010](https://github.com/rust-lang/rust/issues/24010) to be fixed. +The lines marked with `(*)` assume that [#24010](https://github.com/rust-lang/rust/issues/24010) is fixed. # Drawbacks [drawbacks]: #drawbacks From 8a724714d9274bed7dfbd48e18661f0f1a6e6e95 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Mon, 6 Mar 2017 14:12:45 -0500 Subject: [PATCH 2/2] just one lifetime --- text/0000-trait-alias.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-trait-alias.md b/text/0000-trait-alias.md index 12b95005fde..ec9f133b96a 100644 --- a/text/0000-trait-alias.md +++ b/text/0000-trait-alias.md @@ -133,7 +133,7 @@ parameter declarations*. When using a trait alias as an object type, it is subject to object safety restrictions _after_ substituting the aliased traits. This means: -1. It contains an object safe trait, zero or more lifetimes, and zero or more of these other bounds: `Send`, `Sync` (that is, `trait Show = Display + Debug;` would not be object safe). +1. It contains an object safe trait, optionally a lifetime, and zero or more of these other bounds: `Send`, `Sync` (that is, `trait Show = Display + Debug;` would not be object safe). 2. All the associated types of the trait need to be specified. 3. The `where` clause, if present, only contains bounds on `Self`.