diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-27 12:56:26 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-27 12:56:26 +0100 |
commit | d0a4ba294ccf0c925a5ff1115c19a60c6a24b734 (patch) | |
tree | 5caf7619e3486f68516d81971abc3018ddee5323 /crates/hir_def/src/nameres/diagnostics.rs | |
parent | bfb06e17acd4bcb623ad5656490a7a1971980441 (diff) | |
parent | 196cb65ead398f81340de431400103224d7de660 (diff) |
Merge #8997
8997: internal: stop expanding UseTrees during ItemTree lowering r=jonas-schievink a=jonas-schievink
Closes https://github.com/rust-analyzer/rust-analyzer/issues/8908
Messy diff, but `ItemTree` lowering got simpler, since we now have a strict 1-to-1 mapping between `ast::Item` and `ModItem`.
The most messy part is mapping a single `UseTree` back to its `ast::UseTree` counterpart for diagnostics, but I think the ad-hoc source map built during lowering does the job.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/diagnostics.rs')
-rw-r--r-- | crates/hir_def/src/nameres/diagnostics.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/hir_def/src/nameres/diagnostics.rs b/crates/hir_def/src/nameres/diagnostics.rs index 8f2f0ff9f..57c36c3c6 100644 --- a/crates/hir_def/src/nameres/diagnostics.rs +++ b/crates/hir_def/src/nameres/diagnostics.rs | |||
@@ -2,9 +2,15 @@ | |||
2 | 2 | ||
3 | use cfg::{CfgExpr, CfgOptions}; | 3 | use cfg::{CfgExpr, CfgOptions}; |
4 | use hir_expand::MacroCallKind; | 4 | use hir_expand::MacroCallKind; |
5 | use la_arena::Idx; | ||
5 | use syntax::ast; | 6 | use syntax::ast; |
6 | 7 | ||
7 | use crate::{nameres::LocalModuleId, path::ModPath, AstId}; | 8 | use crate::{ |
9 | item_tree::{self, ItemTreeId}, | ||
10 | nameres::LocalModuleId, | ||
11 | path::ModPath, | ||
12 | AstId, | ||
13 | }; | ||
8 | 14 | ||
9 | #[derive(Debug, PartialEq, Eq)] | 15 | #[derive(Debug, PartialEq, Eq)] |
10 | pub enum DefDiagnosticKind { | 16 | pub enum DefDiagnosticKind { |
@@ -12,7 +18,7 @@ pub enum DefDiagnosticKind { | |||
12 | 18 | ||
13 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, | 19 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, |
14 | 20 | ||
15 | UnresolvedImport { ast: AstId<ast::Use>, index: usize }, | 21 | UnresolvedImport { id: ItemTreeId<item_tree::Import>, index: Idx<ast::UseTree> }, |
16 | 22 | ||
17 | UnconfiguredCode { ast: AstId<ast::Item>, cfg: CfgExpr, opts: CfgOptions }, | 23 | UnconfiguredCode { ast: AstId<ast::Item>, cfg: CfgExpr, opts: CfgOptions }, |
18 | 24 | ||
@@ -53,10 +59,10 @@ impl DefDiagnostic { | |||
53 | 59 | ||
54 | pub(super) fn unresolved_import( | 60 | pub(super) fn unresolved_import( |
55 | container: LocalModuleId, | 61 | container: LocalModuleId, |
56 | ast: AstId<ast::Use>, | 62 | id: ItemTreeId<item_tree::Import>, |
57 | index: usize, | 63 | index: Idx<ast::UseTree>, |
58 | ) -> Self { | 64 | ) -> Self { |
59 | Self { in_module: container, kind: DefDiagnosticKind::UnresolvedImport { ast, index } } | 65 | Self { in_module: container, kind: DefDiagnosticKind::UnresolvedImport { id, index } } |
60 | } | 66 | } |
61 | 67 | ||
62 | pub(super) fn unconfigured_code( | 68 | pub(super) fn unconfigured_code( |