Skip to content

Commit 90e0fed

Browse files
committed
Clean up check_full_res
1 parent 9a8ca69 commit 90e0fed

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -571,30 +571,21 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
571571
current_item: &Option<String>,
572572
extra_fragment: &Option<String>,
573573
) -> Option<Res> {
574-
let check_full_res_inner = |this: &Self, result: Result<Res, ErrorKind<'_>>| {
575-
let res = match result {
576-
Ok(res) => Some(res),
577-
Err(ErrorKind::Resolve(box kind)) => kind.full_res(),
578-
Err(ErrorKind::AnchorFailure(AnchorFailure::RustdocAnchorConflict(res))) => {
579-
Some(res)
580-
}
581-
Err(ErrorKind::AnchorFailure(AnchorFailure::MultipleAnchors)) => None,
582-
};
583-
this.kind_side_channel.take().map(|(kind, id)| Res::Def(kind, id)).or(res)
584-
};
585-
// cannot be used for macro namespace
586-
let check_full_res = |this: &Self, ns| {
587-
let result = this.resolve(path_str, ns, current_item, module_id, extra_fragment);
588-
check_full_res_inner(this, result.map(|(res, _)| res))
574+
// resolve can't be used for macro namespace
575+
let result = match ns {
576+
Namespace::MacroNS => self.macro_resolve(path_str, module_id).map_err(ErrorKind::from),
577+
Namespace::TypeNS | Namespace::ValueNS => self
578+
.resolve(path_str, ns, current_item, module_id, extra_fragment)
579+
.map(|(res, _)| res),
589580
};
590-
let check_full_res_macro = |this: &Self| {
591-
let result = this.macro_resolve(path_str, module_id);
592-
check_full_res_inner(this, result.map_err(ErrorKind::from))
581+
582+
let res = match result {
583+
Ok(res) => Some(res),
584+
Err(ErrorKind::Resolve(box kind)) => kind.full_res(),
585+
Err(ErrorKind::AnchorFailure(AnchorFailure::RustdocAnchorConflict(res))) => Some(res),
586+
Err(ErrorKind::AnchorFailure(AnchorFailure::MultipleAnchors)) => None,
593587
};
594-
match ns {
595-
Namespace::MacroNS => check_full_res_macro(self),
596-
Namespace::TypeNS | Namespace::ValueNS => check_full_res(self, ns),
597-
}
588+
self.kind_side_channel.take().map(|(kind, id)| Res::Def(kind, id)).or(res)
598589
}
599590
}
600591

0 commit comments

Comments
 (0)