about summary refs log tree commit diff
path: root/src/libsyntax/ext/tt/transcribe.rs
AgeCommit message (Collapse)AuthorLines
2019-09-22rename libsyntax::ext::tt to mbeAleksey Kladov-398/+0
mbe stands for macro-by-example
2019-09-20factor out pluralisation remains after #64280gaolei-2/+3
2019-09-06Correct pluralisation of various diagnostic messagesvarkor-2/+7
2019-08-23hygiene: Require passing transparency explicitly to `apply_mark`Vadim Petrochenkov-11/+33
2019-07-25Remove needless indirection through RcMark Rousskov-13/+11
NamedMatch is already cheap to clone due to Lrc's inside.
2019-07-20Auto merge of #62008 - ia0:issues_61053, r=petrochenkovbors-1/+1
Add meta-variable checks in macro definitions This is an implementation of #61053. It is not sound (some errors are not reported) and not complete (reports may not be actual errors). This is due to the possibility to define macros in macros in indirect ways. See module documentation of `macro_check` for more details. What remains to be done: - [x] Migrate from an error to an allow-by-default lint. - [x] Add more comments in particular for the handling of nested macros. - [x] Add more tests if needed. - [x] Try to avoid cloning too much (one idea is to use lists on the stack). - [ ] Run crater with deny-by-default lint (measure rate of false positives). - [ ] Remove extra commit for deny-by-default lint - [x] Create a PR to remove the old `question_mark_macro_sep` lint #62160
2019-07-19Remember the span of the Kleene operator in macrosJulien Cretin-1/+1
This is needed for having complete error messages where reporting macro variable errors. Here is what they would look like: error: meta-variable repeats with different kleene operator --> $DIR/issue-61053-different-kleene.rs:3:57 | LL | ( $( $i:ident = $($j:ident),+ );* ) => { $( $( $i = $j; )* )* }; | - expected repetition ^^ - conflicting repetition
2019-07-19Adjust other names after the `Mark` renamingVadim Petrochenkov-5/+5
2019-07-01Convert more usages overChris Gregory-1/+1
2019-06-26Fix clippy::redundant_field_namesIgor Matuszewski-3/+3
2019-06-08syntax: Move most of the `TokenKind` methods to `Token`Vadim Petrochenkov-2/+2
2019-06-08syntax: Keep full `Token`s for `macro_rules` separatorsVadim Petrochenkov-12/+7
2019-06-06Some code cleanup and tidy/test fixesVadim Petrochenkov-1/+1
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-4/+4
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-6/+6
2019-06-06syntax: Rename `Token` into `TokenKind`Vadim Petrochenkov-3/+3
2019-06-06Always use token kinds through `token` module rather than `Token` typeVadim Petrochenkov-1/+1
2019-05-22these errors can happen after allMark Mansi-8/+10
2019-05-10turn a couple of fixmes into span_bugsMark Mansi-9/+7
2019-05-08fix incorrect assertMark Mansi-1/+4
2019-05-07lots of comments + minor cleanupMark Mansi-14/+133
2019-05-07avoid extra copyMark Mansi-13/+12
2019-05-06rustfmtMark Mansi-50/+50
2019-02-18Avoid a `clone()` in `transcribe()`.Nicholas Nethercote-2/+1
The current code (expensively) clones the value within an `Rc`. This commit changes things so that the `Rc` itself is (cheaply) cloned instead, avoid some allocations. This requires converting a few `Rc` instances to `Lrc`.
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-1/+2
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-07libsyntax => 2018Taiki Endo-11/+12
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-2/+4
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-08Make `TokenStream` less recursive.Nicholas Nethercote-3/+3
`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-12Rename `TokenStream::concat` and remove `TokenStream::concat_rc_vec`.Nicholas Nethercote-2/+2
`TokenStream::new` is a better name for the former, and the latter is now just equivalent to `TokenStream::Stream`.
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-5/+6
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-10-26Remove redundant cloneShotaro Yamada-2/+2
2018-09-26Remove OneVectorljedrz-2/+2
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-7/+7
2018-08-28Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.Eduard-Mihai Burtescu-6/+6
2018-08-23Use optimized SmallVec implementationIgor Gutorov-1/+1
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-2/+2
2018-04-06Use `Span::apply_mark` where possibleVadim Petrochenkov-3/+3
2018-04-06Use `Span` instead of `SyntaxContext` in `Ident`Vadim Petrochenkov-1/+1
2018-03-22Clean up raw identifier handling when recovering tokens from AST.Lymia Aluysia-1/+1
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-1/+1
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-3/+4
2017-08-30Make fields of `Span` privateVadim Petrochenkov-3/+3
2017-06-26Add `LazyTokenStream`.Jeffrey Seyfried-1/+1
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-26/+34
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-08Speed up expansion.Mark Simulacrum-8/+9
This reduces duplication, thereby increasing expansion speed.
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-3/+3
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-03-30Improve `Path` spans.Jeffrey Seyfried-8/+1
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-16/+20
2017-02-28Merge `repeat_idx` and `repeat_len`.Jeffrey Seyfried-17/+15