aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/completion/src/render/macro_.rs16
-rw-r--r--crates/hir/src/code_model.rs9
-rw-r--r--crates/ide/src/display/navigation_target.rs19
-rw-r--r--crates/ide/src/hover.rs9
4 files changed, 11 insertions, 42 deletions
diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs
index 95408ff9a..0612591fd 100644
--- a/crates/completion/src/render/macro_.rs
+++ b/crates/completion/src/render/macro_.rs
@@ -39,20 +39,13 @@ impl<'a> MacroRender<'a> {
39 } 39 }
40 40
41 fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { 41 fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
42 // FIXME: Currently proc-macro do not have ast-node,
43 // such that it does not have source
44 // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
45 if self.macro_.is_proc_macro() {
46 return None;
47 }
48
49 let mut builder = 42 let mut builder =
50 CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()) 43 CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label())
51 .kind(CompletionItemKind::Macro) 44 .kind(CompletionItemKind::Macro)
52 .set_documentation(self.docs.clone()) 45 .set_documentation(self.docs.clone())
53 .set_deprecated(self.ctx.is_deprecated(self.macro_)) 46 .set_deprecated(self.ctx.is_deprecated(self.macro_))
54 .add_import(import_to_add) 47 .add_import(import_to_add)
55 .detail(self.detail()); 48 .detail(self.detail()?);
56 49
57 let needs_bang = self.needs_bang(); 50 let needs_bang = self.needs_bang();
58 builder = match self.ctx.snippet_cap() { 51 builder = match self.ctx.snippet_cap() {
@@ -95,10 +88,9 @@ impl<'a> MacroRender<'a> {
95 format!("{}!", self.name) 88 format!("{}!", self.name)
96 } 89 }
97 90
98 fn detail(&self) -> String { 91 fn detail(&self) -> Option<String> {
99 #[allow(deprecated)] 92 let ast_node = self.macro_.source(self.ctx.db())?.value;
100 let ast_node = self.macro_.source_old(self.ctx.db()).value; 93 Some(macro_label(&ast_node))
101 macro_label(&ast_node)
102 } 94 }
103} 95}
104 96
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 285905e96..62237f481 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -983,14 +983,7 @@ impl MacroDef {
983 983
984 /// XXX: this parses the file 984 /// XXX: this parses the file
985 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { 985 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
986 // FIXME: Currently proc-macro do not have ast-node, 986 self.source(db)?.value.name().map(|it| it.as_name())
987 // such that it does not have source
988 // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
989 if self.is_proc_macro() {
990 return None;
991 }
992 #[allow(deprecated)]
993 self.source_old(db).value.name().map(|it| it.as_name())
994 } 987 }
995 988
996 /// Indicate it is a proc-macro 989 /// Indicate it is a proc-macro
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index efa0418ad..5dc3f4128 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -210,15 +210,7 @@ impl ToNav for FileSymbol {
210impl TryToNav for Definition { 210impl TryToNav for Definition {
211 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { 211 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
212 match self { 212 match self {
213 Definition::Macro(it) => { 213 Definition::Macro(it) => it.try_to_nav(db),
214 // FIXME: Currently proc-macro do not have ast-node,
215 // such that it does not have source
216 // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
217 if it.is_proc_macro() {
218 return None;
219 }
220 Some(it.to_nav(db))
221 }
222 Definition::Field(it) => Some(it.to_nav(db)), 214 Definition::Field(it) => Some(it.to_nav(db)),
223 Definition::ModuleDef(it) => it.try_to_nav(db), 215 Definition::ModuleDef(it) => it.try_to_nav(db),
224 Definition::SelfType(it) => Some(it.to_nav(db)), 216 Definition::SelfType(it) => Some(it.to_nav(db)),
@@ -366,10 +358,9 @@ impl ToNav for hir::Field {
366 } 358 }
367} 359}
368 360
369impl ToNav for hir::MacroDef { 361impl TryToNav for hir::MacroDef {
370 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 362 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
371 #[allow(deprecated)] 363 let src = self.source(db)?;
372 let src = self.source_old(db);
373 log::debug!("nav target {:#?}", src.value.syntax()); 364 log::debug!("nav target {:#?}", src.value.syntax());
374 let mut res = NavigationTarget::from_named( 365 let mut res = NavigationTarget::from_named(
375 db, 366 db,
@@ -377,7 +368,7 @@ impl ToNav for hir::MacroDef {
377 SymbolKind::Macro, 368 SymbolKind::Macro,
378 ); 369 );
379 res.docs = self.docs(db); 370 res.docs = self.docs(db);
380 res 371 Some(res)
381 } 372 }
382} 373}
383 374
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index c192e3ed7..a18dcdd8e 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -327,14 +327,7 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
327 let mod_path = definition_mod_path(db, &def); 327 let mod_path = definition_mod_path(db, &def);
328 return match def { 328 return match def {
329 Definition::Macro(it) => { 329 Definition::Macro(it) => {
330 // FIXME: Currently proc-macro do not have ast-node, 330 let label = macro_label(&it.source(db)?.value);
331 // such that it does not have source
332 // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
333 if it.is_proc_macro() {
334 return None;
335 }
336 #[allow(deprecated)]
337 let label = macro_label(&it.source_old(db).value);
338 from_def_source_labeled(db, it, Some(label), mod_path) 331 from_def_source_labeled(db, it, Some(label), mod_path)
339 } 332 }
340 Definition::Field(def) => { 333 Definition::Field(def) => {