]> git.lizzy.rs Git - rust.git/commit
auto merge of #6267 : huonw/rust/syntax-deriving-generaliseder, r=nikomatsakis
authorbors <bors@rust-lang.org>
Wed, 8 May 2013 14:24:39 +0000 (07:24 -0700)
committerbors <bors@rust-lang.org>
Wed, 8 May 2013 14:24:39 +0000 (07:24 -0700)
commit8f94ac6118a3ce97d3d1186b38217a6ca4803771
tree31cd64d5fce64b71314c8ef1e9efcdae07f7e5ff
parent37becd887e74383cafd2930a87dfbb8f19c5af15
parent08c80544662f53867551e689e47f8c4f363199cd
auto merge of #6267 : huonw/rust/syntax-deriving-generaliseder, r=nikomatsakis

This "finishes" the generic deriving code (which I started in #5640), in the sense it supports everything that I can think of being useful. (Including lifetimes and type parameters on methods and traits, arguments and return values of (almost) any type, static methods.)

It closes #6149, but met with #6257, so the following doesn't work:
```rust
#[deriving(TotalEq)]
struct Foo<'self>(&'self int);
```
(It only fails for `TotalOrd`, `TotalEq` and `Clone`, since they are the only ones that call a method directly on sub-elements of the type, which means that the auto-deref interferes with the pointer.)

It also makes `Rand` (chooses a random variant, fills the fields with random values, including recursively for recursive types) and `ToStr` (`x.to_str()` is the same as `fmt!("%?", x)`) derivable, as well as converting IterBytes to the generic code (which made the code 2.5x shorter, more robust and added support for tuple structs).

({En,De}codable are trickier, so I'll convert them over later.)