Skip to content

Commit eb9b360

Browse files
committed
Auto merge of #12584 - Veykril:attr-diag, r=Veykril
fix: attribute macros not being properly diagnosed Closes #12582
2 parents 817f46b + 013c6a3 commit eb9b360

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

crates/hir-def/src/nameres/collector.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,17 @@ impl DefCollector<'_> {
436436
let mut unresolved_macros = mem::take(&mut self.unresolved_macros);
437437
let pos = unresolved_macros.iter().position(|directive| {
438438
if let MacroDirectiveKind::Attr { ast_id, mod_item, attr, tree } = &directive.kind {
439+
self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
440+
directive.module_id,
441+
MacroCallKind::Attr {
442+
ast_id: ast_id.ast_id,
443+
attr_args: Default::default(),
444+
invoc_attr_index: attr.id.ast_index,
445+
is_derive: false,
446+
},
447+
None,
448+
));
449+
439450
self.skip_attrs.insert(ast_id.ast_id.with_value(*mod_item), attr.id);
440451

441452
let item_tree = tree.item_tree(self.db);
@@ -1135,19 +1146,7 @@ impl DefCollector<'_> {
11351146

11361147
let def = match resolver(path.clone()) {
11371148
Some(def) if def.is_attribute() => def,
1138-
_ => {
1139-
self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
1140-
directive.module_id,
1141-
MacroCallKind::Attr {
1142-
ast_id,
1143-
attr_args: Default::default(),
1144-
invoc_attr_index: attr.id.ast_index,
1145-
is_derive: false,
1146-
},
1147-
None,
1148-
));
1149-
return true;
1150-
}
1149+
_ => return true,
11511150
};
11521151
if matches!(
11531152
def,
@@ -1389,9 +1388,8 @@ impl DefCollector<'_> {
13891388
ast_id.path.clone(),
13901389
));
13911390
}
1392-
MacroDirectiveKind::Attr { .. } => {
1393-
// FIXME: these should get diagnosed by `reseed_with_unresolved_attribute`
1394-
}
1391+
// These are diagnosed by `reseed_with_unresolved_attribute`, as that function consumes them
1392+
MacroDirectiveKind::Attr { .. } => {}
13951393
}
13961394
}
13971395

0 commit comments

Comments
 (0)