internal: Don't kick off inference in Semantics::descend_into_macros_impl

This commit is contained in:
Lukas Wirth 2021-12-20 13:19:48 +01:00
parent 2ca3834c9f
commit 37a87708ae
2 changed files with 48 additions and 13 deletions

View file

@ -50,7 +50,7 @@ impl SourceAnalyzer {
pub(crate) fn new_for_body(
db: &dyn HirDatabase,
def: DefWithBodyId,
node: InFile<&SyntaxNode>,
node @ InFile { file_id, .. }: InFile<&SyntaxNode>,
offset: Option<TextSize>,
) -> SourceAnalyzer {
let (body, source_map) = db.body_with_source_map(def);
@ -65,7 +65,29 @@ impl SourceAnalyzer {
body: Some(body),
body_source_map: Some(source_map),
infer: Some(db.infer(def)),
file_id: node.file_id,
file_id,
}
}
pub(crate) fn new_for_body_no_infer(
db: &dyn HirDatabase,
def: DefWithBodyId,
node @ InFile { file_id, .. }: InFile<&SyntaxNode>,
offset: Option<TextSize>,
) -> SourceAnalyzer {
let (body, source_map) = db.body_with_source_map(def);
let scopes = db.expr_scopes(def);
let scope = match offset {
None => scope_for(&scopes, &source_map, node),
Some(offset) => scope_for_offset(db, &scopes, &source_map, node.with_value(offset)),
};
let resolver = resolver_for_scope(db.upcast(), def, scope);
SourceAnalyzer {
resolver,
body: Some(body),
body_source_map: Some(source_map),
infer: None,
file_id,
}
}