Skip to content

Commit 196f389

Browse files
committed
try adding diagnostrics for AssocItems
1 parent 1883d1f commit 196f389

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/hir-def/src/data.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::sync::Arc;
44

5-
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, MacroCallId, MacroDefKind};
5+
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, MacroCallId, MacroDefKind, InFile};
66
use smallvec::SmallVec;
77
use syntax::ast;
88

@@ -12,7 +12,7 @@ use crate::{
1212
db::DefDatabase,
1313
intern::Interned,
1414
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId},
15-
nameres::{attr_resolution::ResolvedAttr, proc_macro::ProcMacroKind, DefMap},
15+
nameres::{attr_resolution::ResolvedAttr, proc_macro::ProcMacroKind, DefMap, diagnostics::DefDiagnostic},
1616
type_ref::{TraitRef, TypeBound, TypeRef},
1717
visibility::RawVisibility,
1818
AssocItemId, AstIdWithPath, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId,
@@ -479,6 +479,13 @@ impl<'a> AssocItemCollector<'a> {
479479
'items: for &item in assoc_items {
480480
let attrs = item_tree.attrs(self.db, self.module_id.krate, ModItem::from(item).into());
481481
if !attrs.is_cfg_enabled(self.expander.cfg_options()) {
482+
self.def_map.push_diagnostic(DefDiagnostic::unconfigured_code(
483+
self.module_id.local_id,
484+
InFile::new(tree_id.file_id(), item.ast_id(&item_tree).upcast()),
485+
attrs.cfg().unwrap(),
486+
self.expander.cfg_options().clone()
487+
));
488+
dbg!("Ignoring assoc item!");
482489
continue;
483490
}
484491

0 commit comments

Comments
 (0)