aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/diagnostics.rs27
-rw-r--r--crates/hir/src/lib.rs5
2 files changed, 6 insertions, 26 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index ec0a8fe41..70a4d000d 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -32,7 +32,7 @@ macro_rules! diagnostics {
32 }; 32 };
33} 33}
34 34
35diagnostics![UnresolvedModule, UnresolvedExternCrate, MissingFields]; 35diagnostics![UnresolvedModule, UnresolvedExternCrate, UnresolvedImport, MissingFields];
36 36
37#[derive(Debug)] 37#[derive(Debug)]
38pub struct UnresolvedModule { 38pub struct UnresolvedModule {
@@ -47,30 +47,7 @@ pub struct UnresolvedExternCrate {
47 47
48#[derive(Debug)] 48#[derive(Debug)]
49pub struct UnresolvedImport { 49pub struct UnresolvedImport {
50 pub file: HirFileId, 50 pub decl: InFile<AstPtr<ast::UseTree>>,
51 pub node: AstPtr<ast::UseTree>,
52}
53
54impl Diagnostic for UnresolvedImport {
55 fn code(&self) -> DiagnosticCode {
56 DiagnosticCode("unresolved-import")
57 }
58 fn message(&self) -> String {
59 "unresolved import".to_string()
60 }
61 fn display_source(&self) -> InFile<SyntaxNodePtr> {
62 InFile::new(self.file, self.node.clone().into())
63 }
64 fn as_any(&self) -> &(dyn Any + Send + 'static) {
65 self
66 }
67 fn is_experimental(&self) -> bool {
68 // This currently results in false positives in the following cases:
69 // - `cfg_if!`-generated code in libstd (we don't load the sysroot correctly)
70 // - `core::arch` (we don't handle `#[path = "../<path>"]` correctly)
71 // - proc macros and/or proc macro generated code
72 true
73 }
74} 51}
75 52
76// Diagnostic: unresolved-macro-call 53// Diagnostic: unresolved-macro-call
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index f7883c469..d32246709 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -498,7 +498,10 @@ impl Module {
498 let import = &item_tree[id.value]; 498 let import = &item_tree[id.value];
499 499
500 let use_tree = import.use_tree_to_ast(db.upcast(), file_id, *index); 500 let use_tree = import.use_tree_to_ast(db.upcast(), file_id, *index);
501 sink.push(UnresolvedImport { file: file_id, node: AstPtr::new(&use_tree) }); 501 acc.push(
502 UnresolvedImport { decl: InFile::new(file_id, AstPtr::new(&use_tree)) }
503 .into(),
504 );
502 } 505 }
503 506
504 DefDiagnosticKind::UnconfiguredCode { ast, cfg, opts } => { 507 DefDiagnosticKind::UnconfiguredCode { ast, cfg, opts } => {