Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #15834 - lnicola:derive-docs, r=lnicola
fix: Fix docs path for derive macros Fixes #15831. Not sure about `attr`, I don't think those are documented anyway. And many macros don't work because we pick the wrong path.
bors 2023-11-04
parent 0fec61a · parent 19bf0da · commit 6943228
-rw-r--r--crates/ide/src/doc_links.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 37a1776221..ac15b6aba6 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -602,7 +602,17 @@ fn filename_and_frag_for_def(
}
Definition::Const(c) => format!("const.{}.html", c.name(db)?.display(db.upcast())),
Definition::Static(s) => format!("static.{}.html", s.name(db).display(db.upcast())),
- Definition::Macro(mac) => format!("macro.{}.html", mac.name(db).display(db.upcast())),
+ Definition::Macro(mac) => match mac.kind(db) {
+ hir::MacroKind::Declarative
+ | hir::MacroKind::BuiltIn
+ | hir::MacroKind::Attr
+ | hir::MacroKind::ProcMacro => {
+ format!("macro.{}.html", mac.name(db).display(db.upcast()))
+ }
+ hir::MacroKind::Derive => {
+ format!("derive.{}.html", mac.name(db).display(db.upcast()))
+ }
+ },
Definition::Field(field) => {
let def = match field.parent_def(db) {
hir::VariantDef::Struct(it) => Definition::Adt(it.into()),