fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros

This commit is contained in:
Lukas Wirth 2022-03-18 11:55:53 +01:00
parent bd17933c31
commit 828196be3b
6 changed files with 98 additions and 3 deletions

View file

@ -570,6 +570,12 @@ impl Module {
.collect()
}
pub fn legacy_macros(self, db: &dyn HirDatabase) -> Vec<Macro> {
let def_map = self.id.def_map(db.upcast());
let scope = &def_map[self.id.local_id].scope;
scope.legacy_macros().map(|(_, it)| MacroId::from(it).into()).collect()
}
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
let def_map = self.id.def_map(db.upcast());
def_map[self.id.local_id].scope.impls().map(Impl::from).collect()
@ -1789,6 +1795,10 @@ impl Macro {
}
}
pub fn is_macro_export(self, db: &dyn HirDatabase) -> bool {
matches!(self.id, MacroId::MacroRulesId(id) if db.macro_rules_data(id).macro_export)
}
pub fn kind(&self, db: &dyn HirDatabase) -> MacroKind {
match self.id {
MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander {