about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2014-07-21syntax: Join consecutive string literals in format strings togetherroot-10/+33
Emit a single rt::Piece per consecutive string literals. String literals are split on {{ or }} escapes. Saves a small amount of static storage and emitted code size.
2014-07-21repair macro docsJohn Clements-10/+7
In f1ad425199b0d89dab275a8c8f6f29a73d316f70, I changed the handling of macros, to prevent macro invocations from occurring in fully expanded source. Instead, I added a side table. It contained only the spans of the macros, because this was the only information required in order to make macro export work. However, librustdoc was also affected by this change, since it extracts macro information in a similar way. As a result of the earlier change, exported macros were no longer documented. In order to repair this, I've adjusted the side table to contain whole items, rather than just the spans.
2014-07-20auto merge of #15808 : jakub-/rust/use-mod, r=alexcrichtonbors-1/+1
Implements RFC #168.
2014-07-20auto merge of #15814 : kvark/rust/ast, r=huonwbors-2/+6
Makes working with syntax deriving a bit more pleasuring. For instance, once can use local (non-static) strings anywhere inside `TraitDef` now.
2014-07-20Implement new mod import sugarJakub Wieczorek-1/+1
Implements RFC #168.
2014-07-20auto merge of #15785 : treeman/rust/fix-15780, r=alexcrichtonbors-2/+11
Fix for #15780.
2014-07-19Fixed lifetimes on syntax deriving structs, implemented CloneDzmitry Malyshau-2/+6
2014-07-18Special case for 0 arguments given in format!Jonas Hietala-4/+4
2014-07-18Correct plural of arguments in format_args!Jonas Hietala-2/+11
2014-07-18librustc: Implement unboxed closures with mutable receiversPatrick Walton-8/+29
2014-07-18auto merge of #15732 : bgamari/rust/to-tokens, r=alexcrichtonbors-3/+35
Here I add a `ToTokens` impl for `Attribute_` and `Option<T>`, as well as generalize the impl for `Vec<T>`
2014-07-18auto merge of #15725 : aochagavia/rust/vec, r=alexcrichtonbors-1/+1
* Deprecated `to_owned` in favor of `to_vec` * Deprecated `into_owned` in favor of `into_vec` [breaking-change]
2014-07-17librustc: Remove cross-borrowing of `Box<T>` to `&T` from the language,Patrick Walton-13/+17
except where trait objects are involved. Part of issue #15349, though I'm leaving it open for trait objects. Cross borrowing for trait objects remains because it is needed until we have DST. This will break code like: fn foo(x: &int) { ... } let a = box 3i; foo(a); Change this code to: fn foo(x: &int) { ... } let a = box 3i; foo(&*a); [breaking-change]
2014-07-17Rename functions in the CloneableVector traitAdolfo Ochagavía-1/+1
* Deprecated `to_owned` in favor of `to_vec` * Deprecated `into_owned` in favor of `into_vec` [breaking-change]
2014-07-17syntax: Add ToTokens impl for MethodBen Gamari-0/+2
2014-07-17syntax: Add quote_method!Ben Gamari-0/+13
2014-07-16libsyntax: Remove `Send` from `PtrTy` in `deriving`.Patrick Walton-6/+0
It'll be complex to port to the new explicit-self regime and it seems to be unused.
2014-07-16syntax: Generalize ToTokens impl for Vec<T>Ben Gamari-3/+4
It will now `flat_map` over the elements of a `Vec<T>` if `T: ToTokens`
2014-07-16syntax: Add ToTokens for Attribute_Ben Gamari-0/+7
2014-07-16syntax: Add ToTokens for Option<T>Ben Gamari-0/+9
2014-07-15Fix errorsAdolfo Ochagavía-1/+0
2014-07-15Deprecate `str::from_utf8_owned`Adolfo Ochagavía-5/+5
Use `String::from_utf8` instead [breaking-change]
2014-07-13macro expansion for methodsJohn Clements-25/+47
Closes #4621
2014-07-13expansion abstractionJohn Clements-144/+114
2014-07-13add make_method method to MacResult traitJohn Clements-1/+36
this allows macro results to be parsed as methods
2014-07-13remove no-stmt checkJohn Clements-4/+0
nothing wrong with a statement expanding into 0 stmts, that I can see.
2014-07-13macro method unit test case fixJohn Clements-2/+2
2014-07-13refactor Method definition to make space for macrosJohn Clements-19/+23
This change propagates to many locations, but because of the Macro Exterminator (or, more properly, the invariant that it protects), macro invocations can't occur downstream of expansion. This means that in librustc and librustdoc, extracting the desired field can simply assume that it can't be a macro invocation. Functions in ast_util abstract over this check.
2014-07-12auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, ↵bors-11/+42
r=alexcrichton Our AST definition can include macro invocations, which can expand into all kinds of things. Macro invocations are expanded away during expansion time, and the rest of the compiler doesn't have to deal with them. However, we have no way of enforcing this. This patch adds two protective mechanisms. First, it adds a (quick) explicit check that ensures there are no macro invocations remaining in the AST after expansion. Second, it updates the visit and fold mechanisms so that by default, they will not traverse macro invocations. It's easy enough to add this, if desired (it's documented in the source, and examples appear, e.g. in the IdentFinder. Along the way, I also consulted with @sfackler to refactor the macro export mechanism so that it stores macro text spans in a side table, rather than leaving them in the AST.
2014-07-11add Macro ExterminatorJohn Clements-0/+19
the Macro Exterminator ensures that there are no macro invocations in an AST. This should help make later passes confident that there aren't hidden items, methods, expressions, etc.
2014-07-11make walk/visit_mac opt-in onlyJohn Clements-1/+6
macros can expand into arbitrary items, exprs, etc. This means that using a default walker or folder on an AST before macro expansion is complete will miss things (the things that the macros expand into). As a partial fence against this, this commit moves the default traversal of macros into a separate procedure, and makes the default trait implementation signal an error. This means that Folders and Visitors can traverse macros if they want to, but they need to explicitly add an impl that calls the walk_mac or fold_mac procedure This should prevent problems down the road.
2014-07-11use side table to store exported macrosJohn Clements-5/+11
Per discussion with @sfackler, refactored the expander to change the way that exported macros are collected. Specifically, a crate now contains a side table of spans that exported macros go into. This has two benefits. First, the encoder doesn't need to scan through the expanded crate in order to discover exported macros. Second, the expander can drop all expanded macros from the crate, with the pleasant result that a fully expanded crate contains no macro invocations (which include macro definitions).
2014-07-11rename one of the two confusing MacroExpandersJohn Clements-5/+6
There were two things named MacroExpander, which was confusing. I renamed one of them TTMacroExpander. [breaking change]
2014-07-11Removed dead structures after changes to PartialOrd/Ord derivings.Felix S. Klock II-352/+29
Remove the `NonMatchesExplode` variant now that no deriving impl uses it. Removed `EnumNonMatching` entirely. Remove now irrelevant `on_matching` field and `HandleNonMatchingEnums` type. Removed unused `EnumNonMatchFunc` type def. Drive-by: revise `EnumNonMatchCollapsedFunc` doc. Made all calls to `expand_enum_method_body` go directly to `build_enum_match_tuple`. Alpha-rename `enum_nonmatch_g` back to `enum_nonmatch_f` to reduce overall diff noise. Inline sole call of `some_ordering_const`. Inline sole call of `ordering_const`. Removed a bunch of code that became dead after the above changes.
2014-07-11`O(n*k)` code-size deriving on enums (better than previous `O(n^k)`).Felix S. Klock II-43/+455
In the above formulas, `n` is the number of variants, and `k` is the number of self-args fed into deriving. In the particular case of interest (namely `PartialOrd` and `Ord`), `k` is always 2, so we are basically comparing `O(n)` versus `O(n^2)`. Also, the stage is set for having *all* enum deriving codes go through `build_enum_match_tuple` and getting rid of `build_enum_match`. Also, seriously attempted to clean up the code itself. Added a bunch of comments attempting to document what I learned as I worked through the original code and adapted it to this new strategy.
2014-07-11Revise the `const_nonmatching` flag with more info about author's intent.Felix S. Klock II-23/+40
In particular, I want authors of deriving modes to understand what they are opting into (namely quadratic code size or worse) when they select NonMatchesExplode.
2014-07-11Add scaffolding for assigning alpha-numeric codes to rustc diagnosticsJakub Wieczorek-2/+8
2014-07-09Fix all the test falloutCorey Richardson-38/+38
2014-07-09ast: make Name its own typeCorey Richardson-10/+22
2014-07-09syntax: don't parse numeric literals in the lexerCorey Richardson-36/+5
This removes a bunch of token types. Tokens now store the original, unaltered numeric literal (that is still checked for correctness), which is parsed into an actual number later, as needed, when creating the AST. This can change how syntax extensions work, but otherwise poses no visible changes. [breaking-change]
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-5/+5
This shuffles things around a bit so that LIT_CHAR and co store an Ident which is the original, unaltered literal in the source. When creating the AST, unescape and postprocess them. This changes how syntax extensions can work, slightly, but otherwise poses no visible changes. To get a useful value out of one of these tokens, call `parse::{char_lit, byte_lit, bin_lit, str_lit}` [breaking-change]
2014-07-09syntax: doc comments all the thingsCorey Richardson-406/+397
2014-07-08carry self ident forward through re-parsingJohn Clements-7/+24
formerly, the self identifier was being discarded during parsing, which stymies hygiene. The best fix here seems to be to attach a self identifier to ExplicitSelf_, a change that rippled through the rest of the compiler, but without any obvious damage.
2014-07-08macro literals should be compared by name onlyJohn Clements-2/+9
2014-07-08implement hygiene for method argsJohn Clements-0/+25
2014-07-08test case for expansion of method macroJohn Clements-2/+13
2014-07-08introducing let-syntaxJohn Clements-2/+27
The let-syntax expander is different in that it doesn't apply a mark to its token trees before expansion. This is used for macro_rules, and it's because macro_rules is essentially MTWT's let-syntax. You don't want to mark before expand sees let-syntax, because there's no "after" syntax to mark again. In some sense, the cleaner approach might be to introduce a new AST node that macro_rules expands into; this would make it clearer that the expansion of a macro is distinct from the addition of a new macro binding. This should work for now, though...
2014-07-08self arg macro test caseJohn Clements-0/+13
2014-07-08test harness cleanupJohn Clements-27/+20
2014-07-08added test for method arg hygieneJohn Clements-0/+13