summary refs log tree commit diff
path: root/src/libsyntax/ext/tt/macro_parser.rs
AgeCommit message (Collapse)AuthorLines
2017-08-30Make fields of `Span` privateVadim Petrochenkov-3/+4
2017-08-21Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakisbors-3/+1
syntax: Relax path grammar TLDR: Accept the disambiguator `::` in "type" paths (`Type::<Args>`), accept the disambiguator `::` before parenthesized generic arguments (`Fn::(Args)`). The "turbofish" disambiguator `::<>` in expression paths is a necessary evil required for path parsing to be both simple and to give reasonable results. Since paths in expressions usually refer to values (but not necessarily, e.g. `Struct::<u8> { field: 0 }` is disambiguated, but refers to a type), people often consider `::<>` to be inherent to *values*, and not *expressions* and want to write disambiguated paths for values even in contexts where disambiguation is not strictly necessary, for example when a path is passed to a macro `m!(Vec::<i32>::new)`. The problem is that currently, if the disambiguator is not *required*, then it's *prohibited*. This results in confusion - see https://github.com/rust-lang/rust/issues/41740, https://internals.rust-lang.org/t/macro-path-uses-novel-syntax/5561. This PR makes the disambiguator *optional* instead of prohibited in contexts where it's not strictly required, so people can pass paths to macros in whatever form they consider natural (e.g. disambiguated form for value paths). This PR also accepts the disambiguator in paths with parenthesized arguments (`Fn::(Args)`) for consistency and to simplify testing of stuff like https://github.com/rust-lang/rust/pull/41856#issuecomment-301219194. Closes https://github.com/rust-lang/rust/issues/41740 cc @rust-lang/lang r? @nikomatsakis
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-3/+3
Like #43008 (f668999), but _much more aggressive_.
2017-08-11Issue warnings for unnecessary path disambiguatorsVadim Petrochenkov-3/+1
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-2/+2
2017-07-24Make the macro parser theory description more accuratePiotr Czarnecki-100/+102
2017-07-07Only match a fragment specifier the if it starts with certain tokens.kennytm-4/+70
Fixes #24189. Fixes #26444. Fixes #27832. Fixes #34030. Fixes #35650. Fixes #39964. Fixes the 4th comment in #40569. Fixes the issue blocking #40984.
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-15/+9
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-08Speed up expansion.Mark Simulacrum-17/+23
This reduces duplication, thereby increasing expansion speed.
2017-05-18Add an option to the parser to avoid parsing out of line modulesNick Cameron-2/+6
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-16Rollup merge of #41957 - llogiq:clippy-libsyntax, r=petrochenkovMark Simulacrum-28/+29
Fix some clippy warnings in libsyntax This is mostly removing stray ampersands, needless returns and lifetimes. Basically a lot of small changes.
2017-05-15adressed comments by @kennytm and @petrochenkovAndre Bogus-23/+27
2017-05-15Fix regression in `macro_rules!` name matching.Jeffrey Seyfried-5/+6
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-26/+23
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-04-15Implementation of the `vis` macro matcher.Daniel Keep-0/+1
2017-03-30Improve `Path` spans.Jeffrey Seyfried-1/+1
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-5/+4
2017-03-21Refactor parsing of trait object typesVadim Petrochenkov-1/+1
2017-03-14Cleanup.Jeffrey Seyfried-1/+1
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-21/+11
2017-02-28Add warning cycle.Jeffrey Seyfried-9/+23
2017-02-28Remove `Token::MatchNt`.Jeffrey Seyfried-8/+6
2017-02-28Add `syntax::ext::tt::quoted::{TokenTree, ..}` and remove ↵Jeffrey Seyfried-20/+24
`tokenstream::TokenTree::Sequence`.
2017-01-20Rollup merge of #39118 - jseyfried:token_tree_based_parser, r=nrcAlex Crichton-20/+4
Refactor the parser to consume token trees This is groundwork for efficiently parsing attribute proc macro invocations, bang macro invocations, and `TokenStream`-based attributes and fragment matchers. This improves parsing performance by 8-15% and expansion performance by 0-5% on a sampling of the compiler's crates. r? @nrc
2017-01-17Avoid interpolated token trees.Jeffrey Seyfried-16/+1
2017-01-17Refactor the parser to consume token trees.Jeffrey Seyfried-4/+3
2017-01-17syntax: Rename parse_ty -> parse_ty_no_plus, parse_ty_sum -> parse_tyVadim Petrochenkov-1/+1
2016-12-07macros: fix the expected paths for a non-inline module matched by an `item` ↵Jeffrey Seyfried-3/+4
fragment.
2016-11-12Remove extra level of nesting.Mark-Simulacrum-35/+32
2016-11-12Move next_eis out of main loop to avoid re-allocating and dropping it.Mark-Simulacrum-1/+2
2016-11-12Use SmallVector for eof and bb eis.Mark-Simulacrum-6/+4
2016-11-12Factor out inner current Earley item loop.Mark-Simulacrum-146/+153
Change multiple functions to be non-public. Change nameize to accept an iterator so as to avoid an allocation.
2016-11-12Refactor parse_nt.Mark-Simulacrum-8/+13
2016-11-12Factor out NamedParseResult.Mark-Simulacrum-4/+3
2016-11-12Clean up extraneous &mut.Mark-Simulacrum-1/+1
2016-11-12Refactor to extending from a drain instead of while looping.Mark-Simulacrum-3/+1
2016-11-12Remove unused argument from nameize.Mark-Simulacrum-6/+6
Also makes nameize non-public since it's only locally used.
2016-11-12Cleanup macro_parser::parse, removing a few clones.Mark-Simulacrum-51/+35
2016-11-04Improve `tt`-heavy expansion performance.Jeffrey Seyfried-3/+12
2016-11-03Move doc comment desugaring into the parser.Jeffrey Seyfried-1/+1
2016-11-03Avoid recontructing the `Parser` in `macro_parser.rs`.Jeffrey Seyfried-21/+16
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-7/+6
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-7/+2
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 the stack in `macro_parser::parse`.Nicholas Nethercote-6/+4
This avoids 800,000 heap allocations when compiling html5ever.
2016-10-21Replace the `String` in `ParseResult::Failure` with `Token`.Nicholas Nethercote-6/+13
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 `macro_parser::parse`.Nicholas Nethercote-1/+1
This avoids ~800,000 allocations in html5ever.
2016-10-19Rollup merge of #37208 - jseyfried:fix_partially_consumed_tokens_in_macros, ↵Eduard-Mihai Burtescu-12/+9
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-17Fix partially consumed tokens in macro matchers.Jeffrey Seyfried-12/+9
2016-10-14Avoid many CrateConfig clones.Nicholas Nethercote-1/+1
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.