diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-25 11:48:51 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-25 11:48:51 +0100 |
commit | 463d44075fa0420af7f2afe9d1a6727ae6baa5bd (patch) | |
tree | c40e4d916b2efcd4c7debabbb183b05c08bb7fad /crates/hir/src/doc_links.rs | |
parent | 4f91478e50dc5c2a87235e9be8bd91e3f62de4b4 (diff) | |
parent | 663749beab2eeaaaf2b7d24fe2f721237d1d4dc0 (diff) |
Merge #5869
5869: Minor
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir/src/doc_links.rs')
-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 |