about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
AgeCommit message (Collapse)AuthorLines
2019-05-23syntax: Some code cleanupVadim Petrochenkov-7/+9
2019-05-23syntax: Turn `token::Lit` into a structVadim Petrochenkov-44/+51
2019-05-23syntax: Remove an obsolete hack from literal comparisonsVadim Petrochenkov-9/+1
2019-05-23syntax: Return named errors from literal parsing functionsVadim Petrochenkov-2/+23
2019-05-22Simplify use of keyword symbolsVadim Petrochenkov-37/+37
2019-05-19Improve type size assertionsVadim Petrochenkov-3/+3
Now they - Tell what the new size is, when it changes - Do not require passing an identifier
2019-05-12Auto merge of #60767 - Centril:rollup-4cbsb73, r=Centrilbors-10/+4
Rollup of 4 pull requests Successful merges: - #60694 (Fix HIR printing of existential type #60662) - #60750 (syntax: Remove some legacy nonterminal tokens) - #60751 (Assorted cleanup in parser & AST validation) - #60752 (Fix minor typos for ItemLocalId) Failed merges: r? @ghost
2019-05-12syntax: Remove some legacy nonterminal tokensVadim Petrochenkov-10/+4
2019-05-11Simplify conversions between tokens and semantic literalsVadim Petrochenkov-0/+7
2019-05-11Keep the original token in `ast::Lit`Vadim Petrochenkov-0/+5
2019-05-07Implement built-in await syntaxTaylor Cramer-0/+5
Adds support for .await under the existing async_await feature gate. Moves macro-like await! syntax to the await_macro feature gate. Removes support for `await` as a non-keyword under the `async_await` feature.
2019-03-06Simplify codeEsteban Küber-18/+3
2019-03-06Emit missing unclosed delimiter errorsEsteban Küber-6/+6
2019-02-18Make `interpolated_to_tokenstream` a method on `Nonterminal`.Nicholas Nethercote-82/+81
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-85/+28
It's present within `Token::Interpolated` as an optimization, so that if a nonterminal is converted to a `TokenStream` multiple times, the first-computed value is saved and reused. But in practice it's not needed. `interpolated_to_tokenstream()` is a cold function: it's only called a few dozen times while compiling rustc itself, and a few hundred times across the entire `rustc-perf` suite. Furthermore, when it is called, it is almost always the first conversion, so no benefit is gained from it. So this commit removes `LazyTokenStream`, along with the now-unnecessary `Token::interpolated()`. As well as a significant simplification, the removal speeds things up slightly, mostly due to not having to `drop` the `LazyTokenStream` instances.
2019-02-18Change `Token::interpolated_to_tokenstream()`.Nicholas Nethercote-9/+3
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-10rustc: doc commentsAlexander Regueiro-10/+10
2019-02-09Auto merge of #57944 - estebank:unclosed-delim-the-quickening, r=oli-obkbors-5/+11
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-07Make name resolution handle consts in GenericParamsFromOuterFunction properlyvarkor-1/+2
2019-02-07Adjust parser generic parameter errorsvarkor-1/+0
2019-02-07Parse const genericsvarkor-0/+14
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07unify error handling to single methodEsteban Küber-18/+4
2019-02-07Deduplicate mismatched delimiter errorsEsteban Küber-5/+25
Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently.
2019-02-07libsyntax => 2018Taiki Endo-16/+20
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-1/+1
This commit changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. The first benefit is speed. The functional style does not require any reallocations, due to the use of `P::map` and `MoveMap::move_{,flat_}map`. However, every field in the AST must be overwritten; even those fields that are unchanged are overwritten with the same value. This causes a lot of unnecessary memory writes. The imperative style reduces instruction counts by 1--3% across a wide range of workloads, particularly incremental workloads. The second benefit is conciseness; the imperative style is usually more concise. E.g. compare the old functional style: ``` fn fold_abc(&mut self, abc: ABC) { ABC { a: fold_a(abc.a), b: fold_b(abc.b), c: abc.c, } } ``` with the imperative style: ``` fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) { visit_a(a); visit_b(b); } ``` (The reductions get larger in more complex examples.) Overall, the patch removes over 200 lines of code -- even though the new code has more comments -- and a lot of the remaining lines have fewer characters. Some notes: - The old style used methods called `fold_*`. The new style mostly uses methods called `visit_*`, but there are a few methods that map a `T` to something other than a `T`, which are called `flat_map_*` (`T` maps to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s). - `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to reflect their slightly changed signatures. - Although this commit renames the `fold` module as `mut_visit`, it keeps it in the `fold.rs` file, so as not to confuse git. The next commit will rename the file.
2019-01-20Mark incorrect recovered `char` literals as `TyErr` to avoid type errorsYuki Okushi-2/+1
2019-01-18Change from error to invalidYuki Okushi-1/+1
2019-01-16Add new literal type ErrYuki Okushi-0/+2
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-19Do not interpret mismatches from pretty-printed `$crate` as token stream ↵Vadim Petrochenkov-1/+3
invalidation
2018-12-14Rollup merge of #56699 - nnethercote:SymbolIndex, r=oli-obkkennytm-0/+4
Use a `newtype_index!` within `Symbol`. This shrinks `Option<Symbol>` from 8 bytes to 4 bytes, which shrinks `Token` from 24 bytes to 16 bytes. This reduces instruction counts by up to 1% across a range of benchmarks. r? @oli-obk
2018-12-12Use a `newtype_index!` within `Symbol`.Nicholas Nethercote-0/+4
This shrinks `Option<Symbol>` from 8 bytes to 4 bytes, which shrinks `Token` from 24 bytes to 16 bytes. This reduces instruction counts by up to 1% across a range of benchmarks.
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-5/+2
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-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-04updates all Filename variants to take a fingerprintMatthew Russo-5/+8
2018-12-02Remove not used `DotEq` tokenyui-knk-4/+1
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-11-16Ignore non-semantic tokens for 'probably_eq' streams.Sergio Benitez-2/+3
2018-11-12Change `Lit::short_name` to `Lit::literal_name`.Nicholas Nethercote-7/+7
This avoids a moderately hot allocation in `parse_lit_token`.
2018-09-16Treat `dyn` as a keyword in the 2018 editionvarkor-0/+1
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-3/+3
2018-08-05Enable macros to pass $:literal to another macroMatthew Tran-0/+4
2018-08-01async can begin expressionsTaylor Cramer-0/+1
2018-07-19proc_macro: Preserve spans of attributes on functionsAlex Crichton-5/+44
This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-14Remove most of `Hash` impls from AST and HIR structuresVadim Petrochenkov-2/+2
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-5/+5
2018-06-09Crate-ify and delete unused code in syntax::parseMark Simulacrum-45/+21
2018-06-04Tidy fixes.Crazycolorz5-1/+1
2018-06-04Added is_like_plus to token, and used that in place of equality comparison ↵Crazycolorz5-0/+7
to Plus token.
2018-05-26Add `Ident::as_str` helperVadim Petrochenkov-1/+1
2018-05-23Rollup merge of #50946 - alexcrichton:fix-parse-lifetime, r=petrochenkovkennytm-1/+8
rustc: Fix procedural macros generating lifetime tokens This commit fixes an accidental regression from #50473 where lifetime tokens produced by procedural macros ended up getting lost in translation in the compiler and not actually producing parseable code. The issue lies in the fact that a lifetime's `Ident` is prefixed with `'`. The `glue` implementation for gluing joint tokens together forgot to take this into account so the lifetime inside of `Ident` was missing the leading tick! The `glue` implementation here is updated to create a new `Symbol` in these situations to manufacture a new `Ident` with a leading tick to ensure it parses correctly. Closes #50942