From 60a3785ac27d7361617977bd53e11f2859e97c7c Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 18 Dec 2020 10:26:17 +0800 Subject: Temp fixes panic caused by no ast for proc-macro --- crates/ide/src/display/navigation_target.rs | 10 +++++++++- crates/ide/src/hover.rs | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ide') diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 234f80a3a..73fc73619 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -176,7 +176,15 @@ impl ToNav for FileSymbol { impl TryToNav for Definition { fn try_to_nav(&self, db: &RootDatabase) -> Option { match self { - Definition::Macro(it) => Some(it.to_nav(db)), + Definition::Macro(it) => { + // FIXME: Currently proc-macro do not have ast-node, + // such that it does not have source + // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 + if it.is_proc_macro() { + return None; + } + Some(it.to_nav(db)) + } Definition::Field(it) => Some(it.to_nav(db)), Definition::ModuleDef(it) => it.try_to_nav(db), Definition::SelfType(it) => Some(it.to_nav(db)), diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index ab017d2ad..c03dd74e4 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -324,6 +324,12 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { let mod_path = definition_mod_path(db, &def); return match def { Definition::Macro(it) => { + // FIXME: Currently proc-macro do not have ast-node, + // such that it does not have source + // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 + if it.is_proc_macro() { + return None; + } let label = macro_label(&it.source(db).value); from_def_source_labeled(db, it, Some(label), mod_path) } -- cgit v1.2.3