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_hir/src/source_id.rs | |
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_hir/src/source_id.rs')
-rw-r--r-- | crates/ra_hir/src/source_id.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs index a2bc9a799..0a8fb6d32 100644 --- a/crates/ra_hir/src/source_id.rs +++ b/crates/ra_hir/src/source_id.rs | |||
@@ -92,7 +92,7 @@ impl AstIdMap { | |||
92 | Arc::new(AstIdMap::from_source_file(&source_file)) | 92 | Arc::new(AstIdMap::from_source_file(&source_file)) |
93 | } | 93 | } |
94 | 94 | ||
95 | pub(crate) fn ast_id_to_node_query( | 95 | pub(crate) fn file_item_query( |
96 | db: &impl DefDatabase, | 96 | db: &impl DefDatabase, |
97 | file_id: HirFileId, | 97 | file_id: HirFileId, |
98 | ast_id: ErasedFileAstId, | 98 | ast_id: ErasedFileAstId, |