Don't store SyntaxNodePtr
in CrateDefMap
It is volatile across reparses and makes incrementality worse.
This commit is contained in:
parent
74cb3e96a5
commit
519d870c11
2 changed files with 7 additions and 8 deletions
|
@ -287,7 +287,7 @@ mod diagnostics {
|
||||||
use hir_expand::diagnostics::DiagnosticSink;
|
use hir_expand::diagnostics::DiagnosticSink;
|
||||||
use hir_expand::hygiene::Hygiene;
|
use hir_expand::hygiene::Hygiene;
|
||||||
use hir_expand::InFile;
|
use hir_expand::InFile;
|
||||||
use syntax::{ast, AstPtr, SyntaxNodePtr};
|
use syntax::{ast, AstPtr};
|
||||||
|
|
||||||
use crate::path::ModPath;
|
use crate::path::ModPath;
|
||||||
use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId};
|
use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId};
|
||||||
|
@ -300,7 +300,7 @@ mod diagnostics {
|
||||||
|
|
||||||
UnresolvedImport { ast: AstId<ast::Use>, index: usize },
|
UnresolvedImport { ast: AstId<ast::Use>, index: usize },
|
||||||
|
|
||||||
UnconfiguredCode { ast: InFile<SyntaxNodePtr>, cfg: CfgExpr, opts: CfgOptions },
|
UnconfiguredCode { ast: AstId<ast::Item>, cfg: CfgExpr, opts: CfgOptions },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
@ -341,7 +341,7 @@ mod diagnostics {
|
||||||
|
|
||||||
pub(super) fn unconfigured_code(
|
pub(super) fn unconfigured_code(
|
||||||
container: LocalModuleId,
|
container: LocalModuleId,
|
||||||
ast: InFile<SyntaxNodePtr>,
|
ast: AstId<ast::Item>,
|
||||||
cfg: CfgExpr,
|
cfg: CfgExpr,
|
||||||
opts: CfgOptions,
|
opts: CfgOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -399,9 +399,10 @@ mod diagnostics {
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagnosticKind::UnconfiguredCode { ast, cfg, opts } => {
|
DiagnosticKind::UnconfiguredCode { ast, cfg, opts } => {
|
||||||
|
let item = ast.to_node(db.upcast());
|
||||||
sink.push(InactiveCode {
|
sink.push(InactiveCode {
|
||||||
file: ast.file_id,
|
file: ast.file_id,
|
||||||
node: ast.value.clone(),
|
node: AstPtr::new(&item).into(),
|
||||||
cfg: cfg.clone(),
|
cfg: cfg.clone(),
|
||||||
opts: opts.clone(),
|
opts: opts.clone(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1336,13 +1336,11 @@ impl ModCollector<'_, '_> {
|
||||||
|
|
||||||
fn emit_unconfigured_diagnostic(&mut self, item: ModItem, cfg: &CfgExpr) {
|
fn emit_unconfigured_diagnostic(&mut self, item: ModItem, cfg: &CfgExpr) {
|
||||||
let ast_id = item.ast_id(self.item_tree);
|
let ast_id = item.ast_id(self.item_tree);
|
||||||
let id_map = self.def_collector.db.ast_id_map(self.file_id);
|
|
||||||
let syntax_ptr = id_map.get(ast_id).syntax_node_ptr();
|
|
||||||
|
|
||||||
let ast_node = InFile::new(self.file_id, syntax_ptr);
|
let ast_id = InFile::new(self.file_id, ast_id);
|
||||||
self.def_collector.def_map.diagnostics.push(DefDiagnostic::unconfigured_code(
|
self.def_collector.def_map.diagnostics.push(DefDiagnostic::unconfigured_code(
|
||||||
self.module_id,
|
self.module_id,
|
||||||
ast_node,
|
ast_id,
|
||||||
cfg.clone(),
|
cfg.clone(),
|
||||||
self.def_collector.cfg_options.clone(),
|
self.def_collector.cfg_options.clone(),
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Reference in a new issue