about summary refs log tree commit diff
path: root/src/libsyntax/ext/placeholders.rs
AgeCommit message (Collapse)AuthorLines
2019-02-07libsyntax => 2018Taiki Endo-11/+12
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-42/+37
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-02-05Various improvements in `Folder` impls.Nicholas Nethercote-10/+5
2018-12-25Remove licensesMark Rousskov-10/+0
2018-09-26Remove OneVectorljedrz-6/+6
2018-08-28Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.Eduard-Mihai Burtescu-3/+3
2018-08-23Use optimized SmallVec implementationIgor Gutorov-11/+11
2018-08-19mv (mod) codemap source_mapDonato Sciarra-1/+1
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-14/+15
2018-06-23expansion: Rename `Expansion` to `AstFragment`Vadim Petrochenkov-28/+29
2018-05-22rustc: Correctly pretty-print macro delimitersAlex Crichton-0/+1
This commit updates the `Mac_` AST structure to keep track of the delimiters that it originally had for its invocation. This allows us to faithfully pretty-print macro invocations not using parentheses (e.g. `vec![...]`). This in turn helps procedural macros due to #43081. Closes #50840
2018-04-03expand macro invocations in `extern {}` blocksAustin Bonander-0/+11
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-1/+1
2017-10-17Lifting Generics from MethodSig to TraitItem and ImplItem since we want to ↵Sunjay Varma-2/+3
support generics in each variant of TraitItem and ImplItem
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-9/+9
Like #43008 (f668999), but _much more aggressive_.
2017-07-28syntax: Capture a `TokenStream` when parsing itemsAlex Crichton-0/+2
This is then later used by `proc_macro` to generate a new `proc_macro::TokenTree` which preserves span information. Unfortunately this isn't a bullet-proof approach as it doesn't handle the case when there's still other attributes on the item, especially inner attributes. Despite this the intention here is to solve the primary use case for procedural attributes, attached to functions as outer attributes, likely bare. In this situation we should be able to now yield a lossless stream of tokens to preserve span information.
2017-07-28syntax: Add `tokens: Option<TokenStream>` to ItemAlex Crichton-0/+1
This commit adds a new field to the `Item` AST node in libsyntax to optionally contain the original token stream that the item itself was parsed from. This is currently `None` everywhere but is intended for use later with procedural macros.
2017-03-29Move `syntax::ext::hygiene` to `syntax_pos::hygiene`.Jeffrey Seyfried-2/+2
2017-03-25Fix ICE with nested macros in certain situations.Jeffrey Seyfried-1/+1
2017-03-22Introduce HirId, a replacement for NodeId after lowering to HIR.Michael Woerister-11/+3
HirId has a more stable representation than NodeId, meaning that modifications to one item don't influence (part of) the IDs within other items. The other part is a DefIndex for which there already is a way of stable hashing and persistence. This commit introduces the HirId type and generates a HirId for every NodeId during HIR lowering, but the resulting values are not yet used anywhere, except in consistency checks.
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-15/+0
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-1/+2
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-2/+11
`#![feature(proc_macro)]`.
2016-12-22Refactor how global paths are represented (for both ast and hir).Jeffrey Seyfried-1/+1
2016-12-18Remove scope placeholders, remove method `add_macro` of `ext::base::Resolver`.Jeffrey Seyfried-36/+14
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-2/+2
2016-10-07Cleanup `depth`s.Jeffrey Seyfried-1/+2
2016-09-15Remove `MacroRulesTT`.Jeffrey Seyfried-3/+10
2016-09-13Differentiate between monotonic and non-monotonic expansion andJeffrey Seyfried-3/+7
only assign node ids during monotonic expansion.
2016-09-13Perform node id assignment and `macros_at_scope` construction duringJeffrey Seyfried-4/+57
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-07Implement stackless placeholder expansion.Jeffrey Seyfried-4/+7
2016-09-05Add module `ext::placeholders` with `placeholder()` and `PlaceholderExpander`.Jeffrey Seyfried-0/+172