Skip to content

Commit 2a1a5b2

Browse files
authored
Merge pull request #6 from pnkfelix/associated-type-rebinding
It is an error to incompatibly override an equivalence constraint.
2 parents 5c94f49 + dcec407 commit 2a1a5b2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

text/0000-trait-alias.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ with optional bounds, just like other generic definitions.
160160
You cannot directly `impl` a trait alias, but you can have them as *bounds*, *trait objects* and
161161
*impl Trait*.
162162

163+
----
164+
165+
It is an error to attempt to override a previously specified
166+
equivalence constraint with a non-equivalent type. For example:
167+
168+
```rust
169+
trait SharableIterator = Iterator + Sync;
170+
trait IntIterator = Iterator<Item=i32>;
171+
172+
fn quux1<T: SharableIterator<Item=f64>>(...) { ... } // ok
173+
fn quux2<T: IntIterator<Item=i32>>(...) { ... } // ok (perhaps subject to lint warning)
174+
fn quux3<T: IntIterator<Item=f64>>(...) { ... } // ERROR: `Item` already constrained
175+
176+
trait FloIterator = IntIterator<Item=f64>; // ERROR: `Item` already constrained
177+
```
178+
163179
---
164180

165181
When using a trait alias as a trait object, it is subject to object safety restrictions *after*

0 commit comments

Comments
 (0)