rust/src/libcore
bors 2cb6974856 auto merge of #5640 : dbaupp/rust/syntax-generalise-deriving, r=thestinger
This refactors much of the ast generation required for `deriving` instances into a common interface, so that new instances only need to specify what they do with the actual data, rather than worry about naming function arguments and extracting fields from structs and enum. (This all happens in `generic.rs`. I've tried to make sure it was well commented and explained, since it's a little abstract at points, but I'm sure it's still a little confusing.)

It makes instances like the comparison traits and `Clone` short and easy to write.

Caveats:
- Not surprisingly, this slows the expansion pass (in some cases, dramatically, specifically deriving Ord or TotalOrd on enums with many variants).   However, this shouldn't be too concerning, since in a more realistic case (compiling `core.rc`) the time increased by 0.01s, which isn't worth mentioning. And, it possibly slows type checking very slightly (about 2% worst case), but I'm having trouble measuring it (and I don't understand why this would happen). I think this could be resolved by using traits and encoding it all in the type system so that monomorphisation handles everything, but that would probably be a little tricky to arrange nicely, reduce flexibility and make compiling rustc take longer. (Maybe some judicious use of `#[inline(always)]` would help too; I'll have a bit of a play with it.)
- The abstraction is not currently powerful enough for:
  - `IterBytes`: doesn't support arguments of type other than `&Self`.
  - `Encodable`/`Decodable` (#5090): doesn't support traits with parameters.
  - `Rand` & `FromStr`; doesn't support static functions and arguments of type other than `&Self`.
   - `ToStr`: I don't think it supports returning `~str` yet, but I haven't actually tried.

  (The last 3 are traits that might be nice to have: the derived `ToStr`/`FromStr` could just read/write the same format as `fmt!("%?", x)`, like `Show` and `Read` in Haskell.)
 
  I have ideas to resolve all of these, but I feel like it would essentially be a simpler version of the `mt` & `ty_` parts of `ast.rs`, and I'm not sure if the simplification is worth having 2 copies of similar code.

Also, makes Ord, TotalOrd and TotalEq derivable (closes #4269, #5588 and #5589), although a snapshot is required before they can be used in the rust repo.

If there is anything that is unclear (or incorrect) either here or in the code, I'd like to get it pointed out now, so I can explain/fix it while I'm still intimately familiar with the code.
2013-04-12 04:33:58 -07:00
..
num auto merge of #5769 : gifnksm/rust/range_step, r=bstrie 2013-04-09 07:52:04 -07:00
rt rt: improve mips backend 2013-04-04 18:53:58 +08:00
task core: Remove all but one drop block in favor of finally 2013-04-08 16:16:32 -07:00
unstable rename Linear{Map,Set} => Hash{Map,Set} 2013-04-03 10:30:36 -04:00
at_vec.rs Removing mut fields from vec.rs, at_vec.rs, str.rs, unstable.rs, and cell.rs. 2013-04-03 16:33:23 +02:00
bool.rs bool: implement Ord and TotalOrd 2013-04-11 19:01:03 -04:00
cast.rs Add AbiSet and integrate it into the AST. 2013-03-29 18:36:20 -07:00
cell.rs Add cell#with_mut_ref for handling mutable references to the content. 2013-04-04 11:34:35 -06:00
char.rs Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
cleanup.rs
clone.rs clone: managed boxes need to clone by shallow copy 2013-04-08 16:19:12 -04:00
cmp.rs libcore: combine cmp::Ordering instances in lexical order. 2013-04-12 17:10:26 +10:00
comm.rs
condition.rs
container.rs Revert map.each to something which takes two parameters 2013-04-10 07:51:48 -07:00
core.rc Bump version to 0.7-pre 2013-04-10 13:12:53 -07:00
either.rs
flate.rs
from_str.rs
gc.rs rename Linear{Map,Set} => Hash{Map,Set} 2013-04-03 10:30:36 -04:00
hash.rs Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
hashmap.rs Revert map.each to something which takes two parameters 2013-04-10 07:51:48 -07:00
io.rs auto merge of #5674 : steveklabnik/rust/improve_reader_util_docs, r=catamorphism 2013-04-02 21:18:43 -07:00
iter.rs Added iter_to_vec conversion fn 2013-04-10 16:57:52 +02:00
kinds.rs
libc.rs Fix various warnings, NOTEs, etc 2013-04-05 05:36:03 -04:00
logging.rs
managed.rs
nil.rs
ops.rs
option.rs Refactor so that references to traits are not represented using a type with a 2013-04-05 05:36:02 -04:00
os.rs Add AbiSet and integrate it into the AST. 2013-03-29 18:36:20 -07:00
owned.rs
path.rs
pipes.rs
prelude.rs
ptr.rs Add AbiSet and integrate it into the AST. 2013-03-29 18:36:20 -07:00
rand.rs Fix formatting 2013-04-11 09:12:26 -04:00
reflect.rs Refactor so that references to traits are not represented using a type with a 2013-04-05 05:36:02 -04:00
repr.rs
result.rs Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
run.rs Refactor so that references to traits are not represented using a type with a 2013-04-05 05:36:02 -04:00
stackwalk.rs Add AbiSet and integrate it into the AST. 2013-03-29 18:36:20 -07:00
str.rs Add example for str::subslice_offset 2013-04-11 00:48:31 +02:00
sys.rs Add AbiSet and integrate it into the AST. 2013-03-29 18:36:20 -07:00
to_bytes.rs
to_str.rs Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
trie.rs Revert map.each to something which takes two parameters 2013-04-10 07:51:48 -07:00
tuple.rs Implement Clone for tuples 2013-04-03 19:43:23 +13:00
unicode.rs
unstable.rs core: Remove all but one drop block in favor of finally 2013-04-08 16:16:32 -07:00
util.rs
vec.rs Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00