aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-25 11:47:36 +0100
committerAleksey Kladov <[email protected]>2020-08-25 11:48:00 +0100
commit663749beab2eeaaaf2b7d24fe2f721237d1d4dc0 (patch)
treec40e4d916b2efcd4c7debabbb183b05c08bb7fad
parent4f91478e50dc5c2a87235e9be8bd91e3f62de4b4 (diff)
Minor
-rw-r--r--crates/hir/src/doc_links.rs15
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
3use std::iter::once; 3use std::iter::once;
4 4
5use hir_def::{db::DefDatabase, resolver::Resolver};
5use itertools::Itertools; 6use itertools::Itertools;
7use syntax::ast::Path;
6use url::Url; 8use url::Url;
7 9
8use crate::{db::HirDatabase, Adt, AsName, Crate, Hygiene, ItemInNs, ModPath, ModuleDef}; 10use crate::{db::HirDatabase, Adt, AsName, Crate, Hygiene, ItemInNs, ModPath, ModuleDef};
9use hir_def::{db::DefDatabase, resolver::Resolver};
10use syntax::ast::Path;
11 11
12pub fn resolve_doc_link<T: Resolvable + Clone, D: DefDatabase + HirDatabase>( 12pub 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