Commit Graph

2523 Commits

Author SHA1 Message Date
Jeffrey Seyfried 36c8f6b0d3 Cleanup InternedString. 2016-11-21 09:00:56 +00:00
Jeffrey Seyfried e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried d2f8fb0a0a Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00
Jeffrey Seyfried f177a00ac9 Refactor P<ast::MetaItem> -> ast::MetaItem. 2016-11-20 12:36:41 +00:00
Jeffrey Seyfried a2626410d7 Refactor MetaItemKind to use Names instead of InternedStrings. 2016-11-20 11:46:06 +00:00
Jeffrey Seyfried 3ea2bc4e93 Refactor away ast::Attribute_. 2016-11-20 11:46:00 +00:00
Jeffrey Seyfried 641274f907 Resolve imports during expansion. 2016-11-17 08:07:44 +00:00
Mark-Simulacrum 2189f573ca Remove extra level of nesting. 2016-11-12 07:41:47 -07:00
Mark-Simulacrum 38912ee3d4 Move next_eis out of main loop to avoid re-allocating and dropping it. 2016-11-12 07:41:26 -07:00
Mark-Simulacrum 6046595e34 Use SmallVector for eof and bb eis. 2016-11-12 06:45:06 -07:00
Mark-Simulacrum b8d6686ef3 Factor out inner current Earley item loop.
Change multiple functions to be non-public.
Change nameize to accept an iterator so as to avoid an allocation.
2016-11-12 06:42:40 -07:00
Mark-Simulacrum 27c09864bd Refactor parse_nt. 2016-11-12 06:42:40 -07:00
Mark-Simulacrum 68abb24e8d Factor out NamedParseResult. 2016-11-12 06:42:40 -07:00
Mark-Simulacrum eef10d0b5b Clean up extraneous &mut. 2016-11-12 06:42:40 -07:00
Mark-Simulacrum c9e6089d29 Refactor to extending from a drain instead of while looping. 2016-11-12 06:42:40 -07:00
Mark-Simulacrum 7221b07a07 Remove unused argument from nameize.
Also makes nameize non-public since it's only locally used.
2016-11-12 06:42:40 -07:00
Mark-Simulacrum 568874bc10 Cleanup macro_parser::parse, removing a few clones. 2016-11-12 06:42:40 -07:00
Mark-Simulacrum 7bbebb1f54 Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
bors 4da129d984 Auto merge of #37246 - goffrie:no-loop, r=jseyfried
Don't spin expanding stmt macros.

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 and #37234 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state.

I'm not sold on this strategy (checking `tokens_consumed`), so if anyone has a better idea, I'm all ears!
2016-11-11 02:51:01 -08:00
Jeffrey Seyfried 11195676a0 Elimite $crate before invokng custom derives. 2016-11-10 10:23:35 +00:00
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
Geoffry Song eed86fac91 Don't spin expanding stmt macros.
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-26 22:30:38 -04: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