about summary refs log tree commit diff
path: root/src/libsyntax_ext/proc_macro_server.rs
AgeCommit message (Collapse)AuthorLines
2019-07-27Move proc macro server into libsyntaxVadim Petrochenkov-717/+0
2019-07-19Adjust other names after the `Mark` renamingVadim Petrochenkov-2/+2
2019-07-07syntax: Pre-intern names of all built-in macrosVadim Petrochenkov-2/+2
They always end up interned anyway
2019-06-23Fix meta-variable binding errors in macrosJulien Cretin-1/+1
The errors are either: - The meta-variable used in the right-hand side is not bound (or defined) in the left-hand side. - The meta-variable used in the right-hand side does not repeat with the same kleene operator as its binder in the left-hand side. Either it does not repeat enough, or it uses a different operator somewhere. This change should have no semantic impact.
2019-06-15Remove unnecessary `.clone()`Shotaro Yamada-1/+1
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-8/+8
2019-06-06syntax: Remove duplicate span from `token::Ident`Vadim Petrochenkov-7/+6
2019-06-06syntax: Remove duplicate span from `token::Lifetime`Vadim Petrochenkov-2/+2
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-12/+12
2019-06-06syntax: Rename `Token` into `TokenKind`Vadim Petrochenkov-3/+3
2019-05-29Introduce and use `SyntaxContext::outer_expn_info()`.Nicholas Nethercote-1/+1
It reduces two `hygiene_data` accesses to one on some hot paths.
2019-05-27Avoid unnecessary internings.Nicholas Nethercote-2/+2
Most involving `Symbol::intern` on string literals.
2019-05-23syntax: Some code cleanupVadim Petrochenkov-1/+1
2019-05-23syntax: Turn `token::Lit` into a structVadim Petrochenkov-55/+27
2019-05-22Simplify use of keyword symbolsVadim Petrochenkov-3/+3
2019-03-31Fix lifetime on LocalInternedString::get functionJohn Kåre Alsaker-3/+3
2019-03-27Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkovbors-0/+3
Introduce proc_macro::Span::source_text A function to extract the actual source behind a Span. Background: I would like to use `syn` in a `build.rs` script to parse the rust code, and extract part of the source code. However, `syn` only gives access to proc_macro2::Span, and i would like to get the source code behind that. I opened an issue on proc_macro2 bug tracker for this feature https://github.com/alexcrichton/proc-macro2/issues/110 and @alexcrichton said the feature should first go upstream in proc_macro. So there it is! Since most of the Span API is unstable anyway, this is guarded by the same `proc_macro_span` feature as everything else.
2019-03-16syntax: Introduce `Ident::can_be_raw`Vadim Petrochenkov-6/+2
2019-03-06Simplify codeEsteban Küber-5/+2
2019-03-06Emit missing unclosed delimiter errorsEsteban Küber-2/+2
2019-02-24Use ? in some macrosTaiki Endo-1/+1
2019-02-18Make `interpolated_to_tokenstream` a method on `Nonterminal`.Nicholas Nethercote-1/+1
2019-02-18Change `Token::interpolated_to_tokenstream()`.Nicholas Nethercote-2/+2
It is currently a method of `Token`, but it only is valid to call if `self` is a `Token::Interpolated`. This commit eliminates the possibility of misuse by changing it to an associated function that takes a `Nonterminal`, which also simplifies the call sites. This requires splitting out a new function, `nonterminal_to_string`.
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-1/+1
2019-02-09Auto merge of #57944 - estebank:unclosed-delim-the-quickening, r=oli-obkbors-2/+5
Deduplicate mismatched delimiter errors Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently. Second attempt at #54029, follow up to #53949. Fix #31528.
2019-02-07unify error handling to single methodEsteban Küber-2/+5
2019-02-07Deduplicate mismatched delimiter errorsEsteban Küber-1/+1
Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently.
2019-02-04libsyntax_ext => 2018Taiki Endo-3/+4
2019-01-14Remove `TokenStream::Tree` variant.Nicholas Nethercote-1/+1
`TokenStream::Stream` can represent a token stream containing any number of token trees. `TokenStream::Tree` is the special case representing a single token tree. The latter doesn't occur all that often dynamically, so this commit removes it, which simplifies the code quite a bit. This change has mixed performance effects. - The size of `TokenStream` drops from 32 bytes to 8 bytes, and there is one less case for all the match statements. - The conversion of a `TokenTree` to a `TokenStream` now requires two allocations, for the creation of a single element Lrc<Vec<_>>. (But a subsequent commit in this PR will reduce the main source of such conversions.)
2019-01-08Make `TokenStream` less recursive.Nicholas Nethercote-6/+7
`TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-23Rollup merge of #56964 - nnethercote:TokenStream-IsJoint, r=petrochenkovMazdak Farrokhzad-6/+2
Remove `TokenStream::JointTree`. This is done by adding a new `IsJoint` field to `TokenStream::Tree`, which simplifies a lot of `match` statements. And likewise for `CursorKind`. The commit also adds a new method `TokenTree:stream()` which can replace a choice between `.into()` and `.joint()`.
2018-12-20Remove `TokenStream::JointTree`.Nicholas Nethercote-6/+2
This is done by adding a new `IsJoint` field to `TokenStream::Tree`, which simplifies a lot of `match` statements. And likewise for `CursorKind`. The commit also adds a new method `TokenTree:stream()` which can replace a choice between `.into()` and `.joint()`.
2018-12-19proc_macro: Accept `$crate` as an identifier if it comes from the compilerVadim Petrochenkov-0/+6
2018-12-19proc_macro: Validate tokens coming from the compiler againVadim Petrochenkov-51/+56
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-7/+5
Because it's an extra type layer that doesn't really help; in a couple of places it actively gets in the way, and overall removing it makes the code nicer. It does, however, move `tokenstream::TokenTree` further away from the `TokenTree` in `quote.rs`. More importantly, this change reduces the size of `TokenStream` from 48 bytes to 40 bytes on x86-64, which is enough to slightly reduce instruction counts on numerous benchmarks, the best by 1.5%. Note that `open_tt` and `close_tt` have gone from being methods on `Delimited` to associated methods of `TokenTree`.
2018-12-04adds DocTest filename variant, refactors doctest_offset out of source_map, ↵Matthew Russo-1/+1
fixes remaining test failures
2018-12-02Remove not used `DotEq` tokenyui-knk-1/+0
Currently libproc_macro does not use `DotEq` token. https://github.com/rust-lang/rust/pull/49545 changed libproc_macro to not generate `DotEq` token.
2018-12-01Introduce proc_macro::Span::source_textOlivier Goffart-0/+3
2018-11-30proc_macro: move the rustc server to syntax_ext.Eduard-Mihai Burtescu-0/+751