Resolve macro2's derive helpers in IDE layer

Macro2's generally don't have derive helpers, but currently builtin
derive macros are declared with macro2 syntax, which can have derive
helpers.
This commit is contained in:
Ryo Yoshida 2022-12-06 15:53:03 +09:00
parent cf54b8c3a4
commit 051c6598be
No known key found for this signature in database
GPG key ID: E25698A930586171
2 changed files with 20 additions and 3 deletions

View file

@ -2349,12 +2349,14 @@ impl DeriveHelper {
pub fn name(&self, db: &dyn HirDatabase) -> Name {
match self.derive {
MacroId::Macro2Id(_) => None,
MacroId::Macro2Id(it) => {
db.macro2_data(it).helpers.as_deref().and_then(|it| it.get(self.idx)).cloned()
}
MacroId::MacroRulesId(_) => None,
MacroId::ProcMacroId(proc_macro) => db
.proc_macro_data(proc_macro)
.helpers
.as_ref()
.as_deref()
.and_then(|it| it.get(self.idx))
.cloned(),
}