Also dump the macro sub-namespace of macros
diff --git a/crates/hir-def/src/expr_store/tests/body/block.rs b/crates/hir-def/src/expr_store/tests/body/block.rs
index e36f655..f13f857 100644
--- a/crates/hir-def/src/expr_store/tests/body/block.rs
+++ b/crates/hir-def/src/expr_store/tests/body/block.rs
@@ -326,7 +326,7 @@
- FooWorks : type value
crate
- - foo : macro
+ - foo : macro!
- main : value
"#]],
);
diff --git a/crates/hir-def/src/item_scope.rs b/crates/hir-def/src/item_scope.rs
index 01adef5..204031e 100644
--- a/crates/hir-def/src/item_scope.rs
+++ b/crates/hir-def/src/item_scope.rs
@@ -4,7 +4,7 @@
use std::{fmt, sync::LazyLock};
use base_db::Crate;
-use hir_expand::{AstId, MacroCallId, attrs::AttrId, db::ExpandDatabase, name::Name};
+use hir_expand::{AstId, MacroCallId, attrs::AttrId, name::Name};
use indexmap::map::Entry;
use itertools::Itertools;
use la_arena::Idx;
@@ -19,6 +19,7 @@
AdtId, BuiltinType, ConstId, ExternBlockId, ExternCrateId, FxIndexMap, HasModule, ImplId,
LocalModuleId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
db::DefDatabase,
+ nameres::MacroSubNs,
per_ns::{Item, MacrosItem, PerNs, TypesItem, ValuesItem},
visibility::Visibility,
};
@@ -735,10 +736,16 @@
}
}
- pub(crate) fn dump(&self, db: &dyn ExpandDatabase, buf: &mut String) {
+ pub(crate) fn dump(&self, db: &dyn DefDatabase, buf: &mut String) {
let mut entries: Vec<_> = self.resolutions().collect();
entries.sort_by_key(|(name, _)| name.clone());
+ let print_macro_sub_ns =
+ |buf: &mut String, macro_id: MacroId| match MacroSubNs::from_id(db, macro_id) {
+ MacroSubNs::Bang => buf.push('!'),
+ MacroSubNs::Attr => buf.push('#'),
+ };
+
for (name, def) in entries {
let display_name: &dyn fmt::Display = match &name {
Some(name) => &name.display(db, Edition::LATEST),
@@ -763,8 +770,9 @@
None => (),
}
}
- if let Some(Item { import, .. }) = def.macros {
+ if let Some(Item { def: macro_id, import, .. }) = def.macros {
buf.push_str(" macro");
+ print_macro_sub_ns(buf, macro_id);
match import {
Some(ImportOrExternCrate::Import(_)) => buf.push_str(" (import)"),
Some(ImportOrExternCrate::Glob(_)) => buf.push_str(" (glob)"),
diff --git a/crates/hir-def/src/nameres.rs b/crates/hir-def/src/nameres.rs
index 50958ef..f44187e 100644
--- a/crates/hir-def/src/nameres.rs
+++ b/crates/hir-def/src/nameres.rs
@@ -814,7 +814,7 @@
}
impl MacroSubNs {
- fn from_id(db: &dyn DefDatabase, macro_id: MacroId) -> Self {
+ pub(crate) fn from_id(db: &dyn DefDatabase, macro_id: MacroId) -> Self {
let expander = match macro_id {
MacroId::Macro2Id(it) => it.lookup(db).expander,
MacroId::MacroRulesId(it) => it.lookup(db).expander,
diff --git a/crates/hir-def/src/nameres/tests.rs b/crates/hir-def/src/nameres/tests.rs
index 68f47f5..23d60d5 100644
--- a/crates/hir-def/src/nameres/tests.rs
+++ b/crates/hir-def/src/nameres/tests.rs
@@ -889,7 +889,7 @@
- m : type
crate::m
- - S : type value macro
+ - S : type value macro!
"#]],
);
}
diff --git a/crates/hir-def/src/nameres/tests/globs.rs b/crates/hir-def/src/nameres/tests/globs.rs
index 779f776..62887e2 100644
--- a/crates/hir-def/src/nameres/tests/globs.rs
+++ b/crates/hir-def/src/nameres/tests/globs.rs
@@ -391,24 +391,24 @@
- Trait : type (glob)
- defs : type
- function : value (glob)
- - makro : macro (glob)
+ - makro : macro! (glob)
- reexport : type
crate::defs
- Trait : type
- function : value
- - makro : macro
+ - makro : macro!
crate::reexport
- Trait : type (glob)
- function : value (glob)
- inner : type
- - makro : macro (glob)
+ - makro : macro! (glob)
crate::reexport::inner
- Trait : type (import)
- function : value (import)
- - makro : macro (import)
+ - makro : macro! (import)
"#]],
);
}
diff --git a/crates/hir-def/src/nameres/tests/macros.rs b/crates/hir-def/src/nameres/tests/macros.rs
index 5b60031..9c2ca1b 100644
--- a/crates/hir-def/src/nameres/tests/macros.rs
+++ b/crates/hir-def/src/nameres/tests/macros.rs
@@ -207,8 +207,8 @@
expect![[r#"
crate
- Foo : type
- - bar : macro (import)
- - foo : macro (import)
+ - bar : macro! (import)
+ - foo : macro! (import)
"#]],
);
}
@@ -555,9 +555,9 @@
"#,
expect![[r#"
crate
- - bar : type (import) macro (import)
- - baz : type (import) value macro (import)
- - foo : type macro
+ - bar : type (import) macro! (import)
+ - baz : type (import) value macro! (import)
+ - foo : type macro!
"#]],
);
}
@@ -628,13 +628,13 @@
- OkAliasSuper : type value
- OkCrate : type value
- OkPlain : type value
- - bar : macro
+ - bar : macro!
- m : type
crate::m
- - alias1 : macro (import)
- - alias2 : macro (import)
- - alias3 : macro (import)
+ - alias1 : macro! (import)
+ - alias2 : macro! (import)
+ - alias3 : macro! (import)
- not_found : _
"#]],
);
@@ -794,7 +794,7 @@
"#,
expect![[r#"
crate
- - Clone : type (glob) macro (glob)
+ - Clone : type (glob) macro# (glob)
"#]],
);
}
@@ -910,7 +910,7 @@
expect![[r#"
crate
- S : type value
- - derive : macro
+ - derive : macro#
"#]],
);
}
@@ -1029,13 +1029,13 @@
"#,
expect![[r#"
crate
- - AnotherTrait : macro
- - DummyTrait : macro
+ - AnotherTrait : macro#
+ - DummyTrait : macro#
- TokenStream : type value
- - attribute_macro : value macro
+ - attribute_macro : value macro#
- derive_macro : value
- derive_macro_2 : value
- - function_like_macro : value macro
+ - function_like_macro : value macro!
"#]],
);
}
@@ -1075,9 +1075,9 @@
"#,
expect![[r#"
crate
- - DummyTrait : macro (glob)
- - attribute_macro : macro (glob)
- - function_like_macro : macro (glob)
+ - DummyTrait : macro# (glob)
+ - attribute_macro : macro# (glob)
+ - function_like_macro : macro! (glob)
"#]],
);
}
@@ -1120,7 +1120,7 @@
expect![[r#"
crate
- Foo : type
- - structs : macro
+ - structs : macro!
"#]],
);
}
@@ -1196,8 +1196,8 @@
crate
- A : type value
- B : type value
- - inner_a : macro
- - inner_b : macro
+ - inner_a : macro!
+ - inner_b : macro!
"#]],
);
}
@@ -1228,7 +1228,7 @@
expect![[r#"
crate
- A : type value
- - inner : macro
+ - inner : macro!
"#]],
);
// eager -> MBE -> $crate::mbe
@@ -1257,7 +1257,7 @@
expect![[r#"
crate
- A : type value
- - inner : macro
+ - inner : macro!
"#]],
);
}
@@ -1501,9 +1501,9 @@
expect![[r#"
crate
- Ok : type value
- - bar : macro
+ - bar : macro!
- dep : type (extern)
- - foo : macro
+ - foo : macro!
- ok : value
"#]],
);
@@ -1589,8 +1589,8 @@
expect![[r#"
crate
- Ok : type value
- - bar : macro (import)
- - foo : macro (import)
+ - bar : macro# (import)
+ - foo : macro# (import)
- ok : value
"#]],
);