-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More flexible and robust deriving code #6267
Conversation
… traits. This adds support for static methods, and arguments of most types, traits with type parameters, methods with type parameters (and lifetimes for both), as well as making the code more robust to support deriving on types with lifetimes (i.e. 'self).
The former fills each field of a struct or enum variant with a random value (and picks a random enum variant). The latter makes the .to_str method have the same output as fmt!("%?", ..).
This patch means that the following are I feel like this feature should be added to the documentation somewhere given it doesn't appear at all. I'm willing to do so, but I have no idea where it should go (in the manual presumably, but which section?). |
@pcwalton I just xfail-fast'd the tests that failed on Windows. (I'm not sure if this is the correct thing to do, but they pass perfectly on Linux for me.) |
The problem is that the checkfast procedure does not generate a |
…omatsakis 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.)
Fix or_fun_call for index operator changelog: Fix or_fun_call for index operator Fixes rust-lang#6266
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:
(It only fails for
TotalOrd
,TotalEq
andClone
, 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) andToStr
(x.to_str()
is the same asfmt!("%?", 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.)