diff options
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index fb79272768e..d3efbc3f534 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -571,30 +571,21 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { current_item: &Option<String>, extra_fragment: &Option<String>, ) -> Option<Res> { - let check_full_res_inner = |this: &Self, result: Result<Res, ErrorKind<'_>>| { - let res = match result { - Ok(res) => Some(res), - Err(ErrorKind::Resolve(box kind)) => kind.full_res(), - Err(ErrorKind::AnchorFailure(AnchorFailure::RustdocAnchorConflict(res))) => { - Some(res) - } - Err(ErrorKind::AnchorFailure(AnchorFailure::MultipleAnchors)) => None, - }; - this.kind_side_channel.take().map(|(kind, id)| Res::Def(kind, id)).or(res) - }; - // cannot be used for macro namespace - let check_full_res = |this: &Self, ns| { - let result = this.resolve(path_str, ns, current_item, module_id, extra_fragment); - check_full_res_inner(this, result.map(|(res, _)| res)) + // resolve can't be used for macro namespace + let result = match ns { + Namespace::MacroNS => self.macro_resolve(path_str, module_id).map_err(ErrorKind::from), + Namespace::TypeNS | Namespace::ValueNS => self + .resolve(path_str, ns, current_item, module_id, extra_fragment) + .map(|(res, _)| res), }; - let check_full_res_macro = |this: &Self| { - let result = this.macro_resolve(path_str, module_id); - check_full_res_inner(this, result.map_err(ErrorKind::from)) + + let res = match result { + Ok(res) => Some(res), + Err(ErrorKind::Resolve(box kind)) => kind.full_res(), + Err(ErrorKind::AnchorFailure(AnchorFailure::RustdocAnchorConflict(res))) => Some(res), + Err(ErrorKind::AnchorFailure(AnchorFailure::MultipleAnchors)) => None, }; - match ns { - Namespace::MacroNS => check_full_res_macro(self), - Namespace::TypeNS | Namespace::ValueNS => check_full_res(self, ns), - } + self.kind_side_channel.take().map(|(kind, id)| Res::Def(kind, id)).or(res) } } |
