From b52df9187730abbcd9cbb132f7d184c74b9a3b7f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 26 May 2021 01:01:58 +0200 Subject: Stop expanding UseTrees during ItemTree lowering --- crates/hir/src/lib.rs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 1ecd2391b..01b2de515 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -472,27 +472,13 @@ impl Module { }); } - DefDiagnosticKind::UnresolvedImport { ast, index } => { - let use_item = ast.to_node(db.upcast()); - let hygiene = Hygiene::new(db.upcast(), ast.file_id); - let mut cur = 0; - let mut tree = None; - ModPath::expand_use_item( - db.upcast(), - InFile::new(ast.file_id, use_item), - &hygiene, - |_mod_path, use_tree, _is_glob, _alias| { - if cur == *index { - tree = Some(use_tree.clone()); - } - - cur += 1; - }, - ); + DefDiagnosticKind::UnresolvedImport { id, index } => { + let file_id = id.file_id(); + let item_tree = id.item_tree(db.upcast()); + let import = &item_tree[id.value]; - if let Some(tree) = tree { - sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); - } + let use_tree = import.use_tree_to_ast(db.upcast(), file_id, *index); + sink.push(UnresolvedImport { file: file_id, node: AstPtr::new(&use_tree) }); } DefDiagnosticKind::UnconfiguredCode { ast, cfg, opts } => { -- cgit v1.2.3