feat: Make unqualified derive attributes flyimportable

This commit is contained in:
Lukas Wirth 2021-10-28 19:19:30 +02:00
parent 7fdbdc4ab2
commit ebd63ec1cf
11 changed files with 124 additions and 31 deletions

View file

@ -33,7 +33,7 @@ fn derive_censoring() {
//- proc_macros: derive_identity
#[attr1]
#[derive(Foo)]
#[derive(proc_macros::derive_identity)]
#[derive(proc_macros::DeriveIdentity)]
#[derive(Bar)]
#[attr2]
struct S;
@ -41,7 +41,7 @@ struct S;
expect![[r##"
#[attr1]
#[derive(Foo)]
#[derive(proc_macros::derive_identity)]
#[derive(proc_macros::DeriveIdentity)]
#[derive(Bar)]
#[attr2]
struct S;

View file

@ -103,7 +103,7 @@ pub struct DefMap {
/// Side table with additional proc. macro info, for use by name resolution in downstream
/// crates.
///
/// (the primary purpose is to resolve derive helpers)
/// (the primary purpose is to resolve derive helpers and fetch a proc-macros name)
exported_proc_macros: FxHashMap<MacroDefId, ProcMacroDef>,
edition: Edition,
@ -279,7 +279,9 @@ impl DefMap {
pub fn modules(&self) -> impl Iterator<Item = (LocalModuleId, &ModuleData)> + '_ {
self.modules.iter()
}
pub fn exported_proc_macros(&self) -> impl Iterator<Item = (MacroDefId, Name)> + '_ {
self.exported_proc_macros.iter().map(|(id, def)| (*id, def.name.clone()))
}
pub fn root(&self) -> LocalModuleId {
self.root
}