1231: eagarly clean astd maps r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-05-04 08:54:07 +00:00
commit 8ee8542de2
4 changed files with 9 additions and 3 deletions

View file

@ -60,7 +60,7 @@ pub trait DefDatabase: SourceDatabase {
#[salsa::invoke(crate::source_id::AstIdMap::ast_id_map_query)]
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
#[salsa::invoke(crate::source_id::AstIdMap::file_item_query)]
#[salsa::invoke(crate::source_id::AstIdMap::ast_id_to_node_query)]
fn ast_id_to_node(&self, file_id: HirFileId, ast_id: ErasedFileAstId) -> TreeArc<SyntaxNode>;
#[salsa::invoke(RawItems::raw_items_query)]

View file

@ -92,7 +92,7 @@ impl AstIdMap {
Arc::new(AstIdMap::from_source_file(&source_file))
}
pub(crate) fn file_item_query(
pub(crate) fn ast_id_to_node_query(
db: &impl DefDatabase,
file_id: HirFileId,
ast_id: ErasedFileAstId,

View file

@ -186,6 +186,7 @@ impl RootDatabase {
if let Some(crate_graph) = change.crate_graph {
self.set_crate_graph(Arc::new(crate_graph))
}
self.collect_after_change()
}
fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) {
@ -228,4 +229,9 @@ impl RootDatabase {
self.query(hir::db::RawItemsWithSourceMapQuery).sweep(sweep);
self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
}
pub(crate) fn collect_after_change(&mut self) {
let sweep = SweepStrategy::default().discard_everything().sweep_all_revisions();
self.query(hir::db::AstIdToNodeQuery).sweep(sweep)
}
}

View file

@ -674,7 +674,7 @@ Grammar(
"LifetimeArg": (),
"MacroItems": (
traits: [ "ModuleItemOwner", "FnDefOwner" ],
traits: [ "ModuleItemOwner", "FnDefOwner" ],
),
"MacroStmts" : (