diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-04 16:54:04 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-04 16:54:04 +0100 |
commit | e1ea2500fcc5e136fbe6a14c488f558e28519c45 (patch) | |
tree | 1cbcefd57c0dd75cd1c834e34dd00f9f89e9dd17 /crates/ra_syntax/src | |
parent | fcdb387f0d7e76f325a858e4463efd5d7ed3efc3 (diff) | |
parent | bcf45371ff19882e67300cc483b481450ee129fb (diff) |
Merge #1238
1238: Macro queries r=edwin0cheng a=matklad
In https://github.com/rust-analyzer/rust-analyzer/pull/1231, I've added aggressive clean up of `ast_id_to_node` query.
The result of this query is a `SyntaxTree`, and we don't want to retain syntax trees in memory unless absolutely necessary.
Moreover, `SyntaxTree` has identity equality semantics, meaning that we'll get a diffferent syntax tree for a file after every reparse. That means that `ast_id_to_node` query should not genereally be used in HIR, unless it is behind some kind of salsa firewall, like the `raw` module of name resoulution.
However, that PR resulted in the abysmal performance: turns out we were using ast_id_to_node quite heavily in hir when expanding macros!
So this PR installs the more incremental-friendly query structure:
* converting source to token tree is now a query; changing source without affecting token-trees will now preserve macro expansions
* expand macro (tt -> tt) is now a query as well, so we cache macro expansions *before* parsing them into item lists or expressions, which is nice: we can cache expansion without knowing the calling context!
r? @edwin0cheng
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index cae5d8774..011ef0616 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -674,7 +674,7 @@ Grammar( | |||
674 | "LifetimeArg": (), | 674 | "LifetimeArg": (), |
675 | 675 | ||
676 | "MacroItems": ( | 676 | "MacroItems": ( |
677 | traits: [ "ModuleItemOwner", "FnDefOwner" ], | 677 | traits: [ "ModuleItemOwner", "FnDefOwner" ], |
678 | ), | 678 | ), |
679 | 679 | ||
680 | "MacroStmts" : ( | 680 | "MacroStmts" : ( |