]> git.lizzy.rs Git - rust.git/commit
Auto merge of #21237 - erickt:derive-assoc-types, r=erickt
authorbors <bors@rust-lang.org>
Thu, 26 Mar 2015 13:38:41 +0000 (13:38 +0000)
committerbors <bors@rust-lang.org>
Thu, 26 Mar 2015 13:38:41 +0000 (13:38 +0000)
commit557d4346a26266d2eb13f6b0adf106b8873b0da1
treed090541009a2400121f5bac3bca1002598eade28
parent1501f33e76f6f9621aa08fb0cbbc5f85a5ac7f0f
parent9cabe273d3adb06a19f63460deda96ae224b28bf
Auto merge of #21237 - erickt:derive-assoc-types, r=erickt

This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this:

```rust
type Trait {
    type Type;
}

#[derive(Clone)]
struct Foo<A> where A: Trait {
    a: A,
    b: <A as Trait>::Type,
}
```

Gets expended into this impl:

```rust
impl<A: Clone> Clone for Foo<A> where
    A: Trait,
    <A as Trait>::Type: Clone,
{
    fn clone(&self) -> Foo<T> {
        Foo {
            a: self.a.clone(),
            b: self.b.clone(),
        }
    }
}
```