about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKartavya Vashishtha <sendtokartavya@gmail.com>2022-08-08 16:40:29 +0530
committerKartavya Vashishtha <sendtokartavya@gmail.com>2022-08-08 16:40:29 +0530
commit196f389a708d5e0002a1d3b4e1059d43dc4542fb (patch)
tree7b6fbac88d553eba1bc597f0e6773ad4a982bf17
parent1883d1f14146959cfa9cdf1ed43e5d1ad013e07e (diff)
downloadrust-196f389a708d5e0002a1d3b4e1059d43dc4542fb.tar.gz
rust-196f389a708d5e0002a1d3b4e1059d43dc4542fb.zip
try adding diagnostrics for AssocItems
-rw-r--r--crates/hir-def/src/data.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index 35c8708955a..1b4f4ed04ac 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -2,7 +2,7 @@
 
 use std::sync::Arc;
 
-use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, MacroCallId, MacroDefKind};
+use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, MacroCallId, MacroDefKind, InFile};
 use smallvec::SmallVec;
 use syntax::ast;
 
@@ -12,7 +12,7 @@ use crate::{
     db::DefDatabase,
     intern::Interned,
     item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId},
-    nameres::{attr_resolution::ResolvedAttr, proc_macro::ProcMacroKind, DefMap},
+    nameres::{attr_resolution::ResolvedAttr, proc_macro::ProcMacroKind, DefMap, diagnostics::DefDiagnostic},
     type_ref::{TraitRef, TypeBound, TypeRef},
     visibility::RawVisibility,
     AssocItemId, AstIdWithPath, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId,
@@ -479,6 +479,13 @@ impl<'a> AssocItemCollector<'a> {
         'items: for &item in assoc_items {
             let attrs = item_tree.attrs(self.db, self.module_id.krate, ModItem::from(item).into());
             if !attrs.is_cfg_enabled(self.expander.cfg_options()) {
+                self.def_map.push_diagnostic(DefDiagnostic::unconfigured_code(
+                    self.module_id.local_id,
+                    InFile::new(tree_id.file_id(), item.ast_id(&item_tree).upcast()),
+                    attrs.cfg().unwrap(),
+                    self.expander.cfg_options().clone()
+                ));
+                dbg!("Ignoring assoc item!");
                 continue;
             }