summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving
AgeCommit message (Collapse)AuthorLines
2014-01-08auto merge of #11370 : alexcrichton/rust/issue-10465, r=pwaltonbors-1/+0
Turned out to be a 2-line fix, but the compiler fallout was huge.
2014-01-07Fix remaining cases of leaking importsAlex Crichton-1/+0
2014-01-07'borrowed pointer' -> 'reference'Brian Anderson-1/+1
2014-01-03librustc: Remove `@mut` support from the parserPatrick Walton-4/+4
2013-12-28Stop using @ExtCtxtSteven Fackler-55/+55
2013-12-11Make 'self lifetime illegal.Erik Price-45/+45
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-07syntax::deriving: indicate from which trait type errors (etc) ariseHuon Wilson-4/+22
using the expansion info. Previously something like struct NotEq; #[deriving(Eq)] struct Error { foo: NotEq } would just point to the `foo` field, with no mention of the `deriving(Eq)`. With this patch, the compiler creates a note saying "in expansion of #[deriving(Eq)]" pointing to the Eq.
2013-12-07syntax::deriving: add the cx and span to the TraitDef to reduce duplication.Huon Wilson-226/+251
2013-12-01Box Block, fn_decl, variant and Ty in the AST, as they were inflating ↵Eduard Burtescu-19/+15
critical enum sizes.
2013-11-28Register new snapshotsAlex Crichton-14/+14
2013-11-26libsyntax: Remove all non-`proc` `do` syntax.Patrick Walton-74/+80
2013-11-26librustc: Remove remaining uses of `&fn()` in favor of `||`.Patrick Walton-16/+17
2013-11-19libsyntax: Change all uses of `&fn` to `||`.Patrick Walton-16/+24
2013-11-19Mark some derived methods as #[inline].Huon Wilson-1/+27
ToStr, Encodable and Decodable are not marked as such, since they're already expensive, and lead to large methods, so inlining will bloat the metadata & the binaries. This means that something like #[deriving(Eq)] struct A { x: int } creates an instance like #[doc = "Automatically derived."] impl ::std::cmp::Eq for A { #[inline] fn eq(&self, __arg_0: &A) -> ::bool { match *__arg_0 { A{x: ref __self_1_0} => match *self { A{x: ref __self_0_0} => true && __self_0_0.eq(__self_1_0) } } } #[inline] fn ne(&self, __arg_0: &A) -> ::bool { match *__arg_0 { A{x: ref __self_1_0} => match *self { A{x: ref __self_0_0} => false || __self_0_0.ne(__self_1_0) } } } } (The change being the `#[inline]` attributes.)
2013-11-08Generalize AST and ty::Generics to accept multiple lifetimes.Niko Matsakis-14/+15
2013-11-08syntax::ext: Make type errors in deriving point to the field itself.Huon Wilson-312/+327
This rearranges the deriving code so that #[deriving] a trait on a field that doesn't implement that trait will point to the field in question, e.g. struct NotEq; // doesn't implement Eq #[deriving(Eq)] struct Foo { ok: int, also_ok: ~str, bad: NotEq // error points here. } Unfortunately, this means the error is disconnected from the `deriving` itself but there's no current way to pass that information through to rustc except via the spans, at the moment. Fixes #7724.
2013-10-25libsyntax/librustc: Allow mut qualifier in patterns.Luqman Aden-2/+2
2013-10-22libsyntax/librustc: Allow specifying mut on ~self.Luqman Aden-1/+1
2013-10-22libsyntax/librustc: Allow specifying mut on by-value self.Luqman Aden-1/+1
2013-10-21std: Move sys::log_str to repr::repr_to_str. Further work on #2240.Brian Anderson-3/+4
2013-10-09option: rewrite the API to use compositionDaniel Micay-1/+1
2013-10-08add new enum ast::StrStyle as field to ast::lit_strBenjamin Herr-1/+1
For the benefit of the pretty printer we want to keep track of how string literals in the ast were originally represented in the source code. This commit changes parser functions so they don't extract strings from the token stream without at least also returning what style of string literal it was. This is stored in the resulting ast node for string literals, obviously, for the package id in `extern mod = r"package id"` view items, for the inline asm in `asm!()` invocations. For `asm!()`'s other arguments or for `extern "Rust" fn()` items, I just the style of string, because it seemed disproportionally cumbersome to thread that information through the string processing that happens with those string literals, given the limited advantage raw string literals would provide in these positions. The other syntax extensions don't seem to store passed string literals in the ast, so they also discard the style of strings they parse.
2013-10-02std: Swap {To,From}Primitive to use the 64bit as the unimplemented versionErick Tryzelaar-6/+6
One downside with this current implementation is that since BigInt's default is now 64 bit, we can convert larger BigInt's to a primitive, however the current implementation on 32 bit architectures does not take advantage of this fact.
2013-10-02syntax: swap from .span_fatal to .span_err in #[deriving(FromPrimitive)]Erick Tryzelaar-7/+14
2013-10-02syntax: Add #[deriving(FromPrimitive)] syntax extensionErick Tryzelaar-0/+125
Right now this only works for c-style enums.
2013-10-02syntax: indicate an error when a macro ignores trailing tokens.Huon Wilson-1/+1
That is, only a single expression or item gets parsed, so if there are any extra tokens (e.g. the start of another item/expression) the user should be told, rather than silently dropping them. An example: macro_rules! foo { () => { println("hi"); println("bye); } } would expand to just `println("hi")`, which is almost certainly not what the programmer wanted. Fixes #8012.
2013-09-30syntax: Remove usage of fmt!Alex Crichton-12/+13
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-22/+22
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g' find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g' find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-17extra: minor cleanup of Zero and Default syntax extensionErick Tryzelaar-10/+6
2013-09-12syntax: add #[deriving(Default)] syntax extensionErick Tryzelaar-0/+81
2013-09-10auto merge of #9088 : nikomatsakis/rust/issue-6304-AST-tree-not-DAG, ↵bors-5/+5
r=catamorphism Ensures that each AST node has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two representative tests. Fixes #7971 Fixes #6304 Fixes #8367 Fixes #8754 Fixes #8852 Fixes #2543 Fixes #7654
2013-09-10Delay assignment of node ids until after expansion. Ensures that each AST nodeNiko Matsakis-5/+5
has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two representative tests. Fixes #7971 Fixes #6304 Fixes #8367 Fixes #8754 Fixes #8852 Fixes #2543 Fixes #7654
2013-09-10std::at_vec and vec: Unify build_sized, build_sized_opt into buildblake2-ppc-1/+1
These functions have very few users since they are mostly replaced by iterator-based constructions. Convert a few remaining users in-tree, and reduce the number of functions by basically renaming build_sized_opt to build, and removing the other two. This for both the vec and the at_vec versions.
2013-09-03Modernized a few more types in syntax::astMarvin Löbel-102/+102
2013-09-02Renamed syntax::ast::ident -> IdentMarvin Löbel-43/+43
2013-09-01Modernized a few type names in rustc and syntaxMarvin Löbel-80/+80
2013-08-27librustc: Fix merge fallout.Patrick Walton-1/+0
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-7/+20
This removes the stacking of type parameters that occurs when invoking trait methods, and fixes all places in the standard library that were relying on it. It is somewhat awkward in places; I think we'll probably want something like the `Foo::<for T>::new()` syntax.
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-1/+1
Closes #5495
2013-08-10std: Rename Iterator.transform -> .mapErick Tryzelaar-5/+5
cc #5898
2013-08-07auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichtonbors-16/+47
Some general clean-up relating to deriving: - `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier. - the pointer types didn't have impls for `TotalOrd` or `TotalEq`. - the Makefiles didn't reach deep enough into libsyntax for dependencies. (Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-05Updated std::Option, std::Either and std::ResultMarvin Löbel-1/+1
- Made naming schemes consistent between Option, Result and Either - Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None) - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-04syntax: make #[deriving(TotalOrd)] lazy.Huon Wilson-16/+47
Previously it would call: f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...)) (where s/of1 = 'self/other field 1', and f was std::cmp::lexical_ordering) This meant that every .cmp subcall got evaluated when calling a derived TotalOrd.cmp. This corrects this to use let test = sf1.cmp(&of1); if test == Equal { let test = sf2.cmp(&of2); if test == Equal { // ... } else { test } } else { test } This gives a lexical ordering by short-circuiting on the first comparison that is not Equal.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-20/+20
this has been replaced by `for`
2013-08-03auto merge of #8206 : omasanori/rust/blk-to-block, r=graydonbors-3/+3
Just for consistency.
2013-08-02replace `range` with an external iteratorDaniel Micay-7/+5
2013-08-02Replace 'blk' -> 'block' in AstBuilder.OGINO Masanori-3/+3
I didn't rename variables because they are local and are not parts of the public interfaces. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-16/+16
2013-07-20syntax: modernise attribute handling in syntax::attr.Huon Wilson-40/+39
This does a number of things, but especially dramatically reduce the number of allocations performed for operations involving attributes/ meta items: - Converts ast::meta_item & ast::attribute and other associated enums to CamelCase. - Converts several standalone functions in syntax::attr into methods, defined on two traits AttrMetaMethods & AttributeMethods. The former is common to both MetaItem and Attribute since the latter is a thin wrapper around the former. - Deletes functions that are unnecessary due to iterators. - Converts other standalone functions to use iterators and the generic AttrMetaMethods rather than allocating a lot of new vectors (e.g. the old code would have to allocate a new vector to use functions that operated on &[meta_item] on &[attribute].) - Moves the core algorithm of the #[cfg] matching to syntax::attr, similar to find_inline_attr and find_linkage_metas. This doesn't have much of an effect on the speed of #[cfg] stripping, despite hugely reducing the number of allocations performed; presumably most of the time is spent in the ast folder rather than doing attribute checks. Also fixes the Eq instance of MetaItem_ to correctly ignore spaces, so that `rustc --cfg 'foo(bar)'` now works.
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-15/+25