Commit Graph

2502 Commits

Author SHA1 Message Date
Eduard Burtescu
49772fbf5d syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00
Jeffrey Seyfried
b7eed53b55 Remove field TtReader::next_tok. 2016-11-04 02:39:20 +00:00
Jeffrey Seyfried
23ad6fdb66 Improve tt-heavy expansion performance. 2016-11-04 02:38:54 +00:00
Jeffrey Seyfried
7ae083383d Move doc comment desugaring into the parser. 2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
e2b3fec778 Avoid recontructing the Parser in macro_parser.rs. 2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
3b71646a60 Revert "macros: Improve tt fragments"
This reverts commit 41745f30f7.
2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
eb3ac29a10 Reduce the size of Token and make it cheaper to clone by refactoring
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-11-03 23:48:24 +00:00
iirelu
e593c3b893 Changed most vec! invocations to use square braces
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-31 22:51:40 +00:00
Jeffrey Seyfried
cbd24757eb Move CrateConfig from Crate to ParseSess. 2016-10-29 07:52:58 +00:00
bors
e9b2fcb2fe Auto merge of #37373 - nnethercote:html5ever-more-more, r=nrc
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-28 17:02:01 -07:00
Eduard Burtescu
9908711e5e Implement field shorthands in struct literal expressions. 2016-10-27 03:15:13 +03:00
Nicholas Nethercote
c440a7ae65 Don't use Rc in TokenTreeOrTokenTreeVec.
This avoids 800,000 allocations when compiling html5ever.
2016-10-25 12:20:14 +11:00
Nicholas Nethercote
3fd90d8aa5 Use SmallVector for TtReader::stack.
This avoids 800,000 heap allocations when compiling html5ever. It
requires tweaking `SmallVector` a little.
2016-10-25 11:48:25 +11:00
Nicholas Nethercote
0a16a11c39 Use SmallVector for the stack in macro_parser::parse.
This avoids 800,000 heap allocations when compiling html5ever.
2016-10-25 11:48:20 +11:00
Jeffrey Seyfried
53de24bbd1 Refactor away fields MacroDef::{use_locally, export}. 2016-10-24 00:43:19 +00:00
bors
a117bba125 Auto merge of #37318 - nnethercote:html5ever-more, r=nrc,eddyb
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-22 13:09:24 -07:00
Nicholas Nethercote
b817cf8b57 Replace the String in ParseResult::Failure with Token.
This lets us delay creation of failure messages until they are needed,
which avoids ~1.6M allocations in html5ever.
2016-10-21 20:27:15 +11:00
Nicholas Nethercote
e382267cfb Avoid an unnecessary clone in generic_extensions.
This avoids ~800,000 allocations in html5ever.
2016-10-21 12:58:14 +11:00
Nicholas Nethercote
a935481ae9 Avoid an unnecessary clone in macro_parser::parse.
This avoids ~800,000 allocations in html5ever.
2016-10-21 12:58:06 +11:00
Jeffrey Seyfried
8b0c292a72 Improve $crate. 2016-10-19 10:03:06 +00:00
Eduard-Mihai Burtescu
094eaf0250 Rollup merge of #37208 - jseyfried:fix_partially_consumed_tokens_in_macros, 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-19 08:00:01 +03:00
Eduard-Mihai Burtescu
a6788d0ba8 Rollup merge of #37198 - jseyfried:future_proof_macros_11, r=nrc
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-19 08:00:00 +03:00
Jeffrey Seyfried
9578e1a251 Fix partially consumed tokens in macro matchers. 2016-10-17 23:00:52 +00:00
Jeffrey Seyfried
33e3da831c Use the macro namespace for custom derives. 2016-10-15 22:55:19 +00:00
Jeffrey Seyfried
d902963b6d Refactor syntax::ext::base::Resolver::resolve_invoc. 2016-10-15 20:50:02 +00:00
Nicholas Nethercote
029dceedb9 Avoid many CrateConfig clones.
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-14 16:38:12 +11:00
Jeffrey Seyfried
31e0e12e69 Add support for undetermined macro invocations. 2016-10-11 03:41:48 +00:00
Jeffrey Seyfried
d5281ef681 Merge branch 'persistent_macro_scopes' into cleanup_expanded_macro_use_scopes 2016-10-11 03:41:18 +00:00
Jeffrey Seyfried
f3c7333f51 Cleanup depths. 2016-10-07 21:54:04 +00:00
Jeffrey Seyfried
21b4369322 Refactor away ext::expand::{expand_crate, expand_crate_with_expander}. 2016-10-07 21:54:04 +00:00
Jeffrey Seyfried
09e41b6784 Add macros from plugins in libsyntax_ext::register_builtins. 2016-10-07 21:54:03 +00:00
Jeffrey Seyfried
2df25adbed Combine std_inject::{no_core, no_std} into std_inject::injected_crate_name. 2016-10-07 21:54:01 +00:00
Alex Crichton
2148bdfcc7 rustc: Rename rustc_macro to proc_macro
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-06 11:07:23 -07:00
bors
f3745653e1 Auto merge of #36767 - jseyfried:enforce_rfc_1560_shadowing, r=nrc
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-03 01:30:32 -07:00
Jeffrey Seyfried
c9f81190f2 Refactor ext::base::Resolver::add_ext to only define macros in the crate root. 2016-10-02 06:02:47 +00:00
Jeffrey Seyfried
797eb57aa8 Refactor field expansion_data of Resolver to use a Mark instead of a u32. 2016-10-02 04:25:31 +00:00
Manish Goregaokar
406fe7e3c2 Rollup merge of #34764 - pnkfelix:attrs-on-generic-formals, r=eddyb
First step for #34761
2016-10-01 19:22:39 +05:30
Manish Goregaokar
a73ba8b98c Rollup merge of #35874 - CensoredUsername:stmt_let_typed_fix, r=Manishearth
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-10-01 19:22:08 +05:30
Jonathan Turner
f1ea5cc273 Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakis
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-28 20:21:52 -07:00
Jeffrey Seyfried
ce5ad1da12 Allow non-inline modules in more places. 2016-09-28 22:16:20 +00:00
bors
a059cb2f33 Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrc
Assign def ids and build the module graph during expansion

r? @nrc
2016-09-27 14:11:07 -07:00
Jeffrey Seyfried
f34e49dd90 With --test, make #[test] functions pub in InvocationCollector
and expand the `__test_reexports` in the correct scope.
2016-09-27 06:43:49 +00:00
Jeffrey Seyfried
0613dac042 Avoid aborting after expansion from BuildReducedGraphVisitor errors. 2016-09-27 06:43:48 +00:00
bors
ec7679b460 Auto merge of #36764 - jonathandturner:rollup, r=jonathandturner
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-26 23:30:19 -07:00
Jonathan Turner
02cc578676 Rollup merge of #36721 - TimNN:infinite-emptiness, r=nrc
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-26 17:29:48 -07:00
Jeffrey Seyfried
df0e4bf911 Move ensure_complete_parse into expand.rs. 2016-09-26 11:24:10 +00:00
Tim Neumann
b0dba7439d make emit_feature_err take a ParseSess 2016-09-26 07:07:41 +02:00
Tim Neumann
51ea050457 reject macros with empty repetitions 2016-09-26 06:59:06 +02:00
Jeffrey Seyfried
b90ceddcee Refactor ensure_complete_parse. 2016-09-26 04:29:30 +00:00
Jeffrey Seyfried
4a8467b62d Remove TokResult. 2016-09-26 04:16:55 +00:00