diff options
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/doc_links.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/crates/hir/src/doc_links.rs b/crates/hir/src/doc_links.rs index dd2379bfc..a77758675 100644 --- a/crates/hir/src/doc_links.rs +++ b/crates/hir/src/doc_links.rs | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | use std::iter::once; | 3 | use std::iter::once; |
4 | 4 | ||
5 | use hir_def::{db::DefDatabase, resolver::Resolver}; | ||
5 | use itertools::Itertools; | 6 | use itertools::Itertools; |
7 | use syntax::ast::Path; | ||
6 | use url::Url; | 8 | use url::Url; |
7 | 9 | ||
8 | use crate::{db::HirDatabase, Adt, AsName, Crate, Hygiene, ItemInNs, ModPath, ModuleDef}; | 10 | use crate::{db::HirDatabase, Adt, AsName, Crate, Hygiene, ItemInNs, ModPath, ModuleDef}; |
9 | use hir_def::{db::DefDatabase, resolver::Resolver}; | ||
10 | use syntax::ast::Path; | ||
11 | 11 | ||
12 | pub fn resolve_doc_link<T: Resolvable + Clone, D: DefDatabase + HirDatabase>( | 12 | pub fn resolve_doc_link<T: Resolvable + Clone, D: DefDatabase + HirDatabase>( |
13 | db: &D, | 13 | db: &D, |
@@ -16,12 +16,9 @@ pub fn resolve_doc_link<T: Resolvable + Clone, D: DefDatabase + HirDatabase>( | |||
16 | link_target: &str, | 16 | link_target: &str, |
17 | ) -> Option<(String, String)> { | 17 | ) -> Option<(String, String)> { |
18 | try_resolve_intra(db, definition, link_text, &link_target).or_else(|| { | 18 | try_resolve_intra(db, definition, link_text, &link_target).or_else(|| { |
19 | if let Some(definition) = definition.clone().try_into_module_def() { | 19 | let definition = definition.clone().try_into_module_def()?; |
20 | try_resolve_path(db, &definition, &link_target) | 20 | try_resolve_path(db, &definition, &link_target) |
21 | .map(|target| (target, link_text.to_string())) | 21 | .map(|target| (target, link_text.to_string())) |
22 | } else { | ||
23 | None | ||
24 | } | ||
25 | }) | 22 | }) |
26 | } | 23 | } |
27 | 24 | ||
@@ -57,7 +54,7 @@ fn try_resolve_intra<T: Resolvable, D: DefDatabase + HirDatabase>( | |||
57 | Some(ns @ Namespace::Types) => (resolved.types?.0, ns), | 54 | Some(ns @ Namespace::Types) => (resolved.types?.0, ns), |
58 | Some(ns @ Namespace::Values) => (resolved.values?.0, ns), | 55 | Some(ns @ Namespace::Values) => (resolved.values?.0, ns), |
59 | // FIXME: | 56 | // FIXME: |
60 | Some(Namespace::Macros) => None?, | 57 | Some(Namespace::Macros) => return None, |
61 | }; | 58 | }; |
62 | 59 | ||
63 | // Get the filepath of the final symbol | 60 | // Get the filepath of the final symbol |