about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2016-11-03Revert "macros: Improve `tt` fragments"Jeffrey Seyfried-13/+3
This reverts commit 41745f30f751364bdce14428b7d3ffa5dd028903.
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-50/+63
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-10-31Changed most vec! invocations to use square bracesiirelu-47/+47
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-40/+11
2016-10-28Auto merge of #37373 - nnethercote:html5ever-more-more, r=nrcbors-11/+10
Avoid more allocations when compiling html5ever These three commits reduce the number of allocations performed when compiling html5ever from 13.2M to 10.8M, which speeds up compilation by about 2%. r? @nrc
2016-10-26Don't spin expanding stmt macros.Geoffry Song-1/+3
If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state.
2016-10-27Implement field shorthands in struct literal expressions.Eduard Burtescu-1/+1
2016-10-25Don't use `Rc` in `TokenTreeOrTokenTreeVec`.Nicholas Nethercote-3/+3
This avoids 800,000 allocations when compiling html5ever.
2016-10-25Use `SmallVector` for `TtReader::stack`.Nicholas Nethercote-3/+4
This avoids 800,000 heap allocations when compiling html5ever. It requires tweaking `SmallVector` a little.
2016-10-25Use `SmallVector` for the stack in `macro_parser::parse`.Nicholas Nethercote-6/+4
This avoids 800,000 heap allocations when compiling html5ever.
2016-10-24Refactor away fields `MacroDef::{use_locally, export}`.Jeffrey Seyfried-5/+4
2016-10-22Auto merge of #37318 - nnethercote:html5ever-more, r=nrc,eddybbors-14/+26
Avoid some allocations in the macro parser These three commits reduce the number of heap allocations done when compiling rustc-benchmarks/html5ever-2016-08-25 by 20%, from 16.5M to 13.3M. This speeds up (debug) compilation of it with a stage1 compiler by about 7%.
2016-10-21Replace the `String` in `ParseResult::Failure` with `Token`.Nicholas Nethercote-13/+25
This lets us delay creation of failure messages until they are needed, which avoids ~1.6M allocations in html5ever.
2016-10-21Avoid an unnecessary clone in `generic_extensions`.Nicholas Nethercote-2/+2
This avoids ~800,000 allocations in html5ever.
2016-10-21Avoid an unnecessary clone in `macro_parser::parse`.Nicholas Nethercote-1/+1
This avoids ~800,000 allocations in html5ever.
2016-10-19Improve `$crate`.Jeffrey Seyfried-39/+6
2016-10-19Rollup merge of #37208 - jseyfried:fix_partially_consumed_tokens_in_macros, ↵Eduard-Mihai Burtescu-12/+14
r=nrc macros: fix partially consumed tokens in macro matchers Fixes #37175. This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the `TtReader` once per matcher), which improves expansion performance of the test case from #34630 by ~8%. r? @nrc
2016-10-19Rollup merge of #37198 - jseyfried:future_proof_macros_11, r=nrcEduard-Mihai Burtescu-7/+30
macros 1.1: future proofing and cleanup This PR - uses the macro namespace for custom derives (instead of a dedicated custom derive namespace), - relaxes the shadowing rules for `#[macro_use]`-imported custom derives to match the shadowing rules for ordinary `#[macro_use]`-imported macros, and - treats custom derive `extern crate`s like empty modules so that we can eventually allow, for example, `extern crate serde_derive; use serde_derive::Serialize;` backwards compatibly. r? @alexcrichton
2016-10-17Fix partially consumed tokens in macro matchers.Jeffrey Seyfried-12/+14
2016-10-15Use the macro namespace for custom derives.Jeffrey Seyfried-3/+16
2016-10-15Refactor `syntax::ext::base::Resolver::resolve_invoc`.Jeffrey Seyfried-4/+14
2016-10-14Avoid many CrateConfig clones.Nicholas Nethercote-11/+15
This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig` reference instead of a clone. As a result, it also changes all of the `cfg()` callsites to explicitly clone... except one, because the commit also changes `macro_parser::parse()` to take `&CrateConfig`. This is good, because that function can be hot, and `CrateConfig` is expensive to clone. This change almost halves the number of heap allocations done by rustc for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x faster.
2016-10-11Add support for undetermined macro invocations.Jeffrey Seyfried-6/+37
2016-10-11Merge branch 'persistent_macro_scopes' into cleanup_expanded_macro_use_scopesJeffrey Seyfried-54/+21
2016-10-07Cleanup `depth`s.Jeffrey Seyfried-8/+11
2016-10-07Refactor away `ext::expand::{expand_crate, expand_crate_with_expander}`.Jeffrey Seyfried-31/+10
2016-10-07Add macros from plugins in `libsyntax_ext::register_builtins`.Jeffrey Seyfried-14/+5
2016-10-07Combine `std_inject::{no_core, no_std}` into `std_inject::injected_crate_name`.Jeffrey Seyfried-7/+1
2016-10-06rustc: Rename rustc_macro to proc_macroAlex Crichton-1/+1
This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`, which reflects the general consensus of #35900. A follow up PR to Cargo will be required to purge the `rustc-macro` name as well.
2016-10-03Auto merge of #36767 - jseyfried:enforce_rfc_1560_shadowing, r=nrcbors-3/+8
Enforce the shadowing restrictions from RFC 1560 for today's macros This PR enforces a weakened version of the shadowing restrictions from RFC 1560. More specifically, - If a macro expansion contains a `macro_rules!` macro definition that is used outside of the expansion, the defined macro may not shadow an existing macro. - If a macro expansion contains a `#[macro_use] extern crate` macro import that is used outside of the expansion, the imported macro may not shadow an existing macro. This is a [breaking-change]. For example, ```rust macro_rules! m { () => {} } macro_rules! n { () => { macro_rules! m { () => {} } //< This shadows an existing macro. m!(); //< This is inside the expansion that generated `m`'s definition, so it is OK. } } n!(); m!(); //< This use of `m` is outside the expansion, so it causes the shadowing to be an error. ``` r? @nrc
2016-10-02Refactor `ext::base::Resolver::add_ext` to only define macros in the crate root.Jeffrey Seyfried-3/+3
2016-10-02Refactor field `expansion_data` of `Resolver` to use a `Mark` instead of a ↵Jeffrey Seyfried-0/+5
`u32`.
2016-10-01Rollup merge of #34764 - pnkfelix:attrs-on-generic-formals, r=eddybManish Goregaokar-0/+6
First step for #34761
2016-10-01Rollup merge of #35874 - CensoredUsername:stmt_let_typed_fix, r=ManishearthManish Goregaokar-4/+4
This commit makes the return type of AstBuilder.stmt_let_typed match the return type of other AstBuilder.stmt* functions. This avoids unnecessary boxing/unboxing whenever Stmt's are stored in a Vec, which is the default use case.nnThis is a potentially plugin breaking change.
2016-09-28Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakisJonathan Turner-9/+16
Allow more non-inline modules in blocks Currently, non-inline modules without a `#[path]` attribute are not allowed in blocks. This PR allows non-inline modules that have an ancestor module with a `#[path]` attribute, provided there is not a nearer ancestor block. For example, ```rust fn main() { #[path = "..."] mod foo { mod bar; //< allowed by this PR fn f() { mod bar; //< still an error } } } ``` Fixes #36772. r? @nikomatsakis
2016-09-28Allow non-inline modules in more places.Jeffrey Seyfried-9/+16
2016-09-27Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrcbors-3/+16
Assign def ids and build the module graph during expansion r? @nrc
2016-09-27With `--test`, make `#[test]` functions `pub` in `InvocationCollector`Jeffrey Seyfried-2/+11
and expand the `__test_reexports` in the correct scope.
2016-09-27Avoid aborting after expansion from `BuildReducedGraphVisitor` errors.Jeffrey Seyfried-1/+5
2016-09-26Auto merge of #36764 - jonathandturner:rollup, r=jonathandturnerbors-270/+141
Rollup of 14 pull requests - Successful merges: #36563, #36574, #36586, #36662, #36663, #36669, #36676, #36721, #36723, #36727, #36729, #36742, #36754, #36756 - Failed merges:
2016-09-26Rollup merge of #36721 - TimNN:infinite-emptiness, r=nrcJonathan Turner-1/+38
reject macros with empty repetitions Fixes #5067 by checking the lhs of `macro_rules!` for repetitions which could match an empty token tree.
2016-09-26Move `ensure_complete_parse` into `expand.rs`.Jeffrey Seyfried-0/+12
2016-09-26make emit_feature_err take a ParseSessTim Neumann-1/+1
2016-09-26reject macros with empty repetitionsTim Neumann-1/+38
2016-09-26Refactor `ensure_complete_parse`.Jeffrey Seyfried-36/+19
2016-09-26Remove `TokResult`.Jeffrey Seyfried-161/+29
2016-09-26Refactor `parse_expansion` out of `ResultAnyMacro`.Jeffrey Seyfried-92/+63
2016-09-24Load macros from `#[macro_use]` extern crates in `resolve`.Jeffrey Seyfried-69/+13
2016-09-24Refactor `ext::tt::macro_rules::compile` to take a `ParseSess` instead of an ↵Jeffrey Seyfried-40/+33
`ExtCtxt`.
2016-09-23Add attribute support to generic lifetime and type parameters.Felix S. Klock II-0/+6
I am using `ThinAttributes` rather than a vector for attributes attached to generics, since I expect almost all lifetime and types parameters to not carry any attributes.