Skip to content

Commit 7689857

Browse files
committed
rustdoc: Do not resolve associated item paths unnecessarily
1 parent 7c2283d commit 7689857

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,16 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
505505
module_id: DefId,
506506
) -> Result<(Res, Option<DefId>), UnresolvedPath<'path>> {
507507
if let Some(res) = self.resolve_path(path_str, ns, item_id, module_id) {
508-
match res {
509-
// FIXME(#76467): make this fallthrough to lookup the associated
510-
// item a separate function.
511-
Res::Def(DefKind::AssocFn | DefKind::AssocConst, _) => assert_eq!(ns, ValueNS),
512-
Res::Def(DefKind::AssocTy, _) => assert_eq!(ns, TypeNS),
513-
Res::Def(DefKind::Variant, def_id) => {
514-
let enum_def_id = self.cx.tcx.parent(def_id).expect("variant has no parent");
515-
return Ok((Res::Def(DefKind::Enum, enum_def_id), Some(def_id)));
508+
return Ok(match res {
509+
Res::Def(
510+
DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::Variant,
511+
def_id,
512+
) => {
513+
let parent_def_id = self.cx.tcx.parent(def_id).unwrap();
514+
(Res::from_def_id(self.cx.tcx, parent_def_id), Some(def_id))
516515
}
517-
// Not a trait item; just return what we found.
518-
_ => return Ok((res, None)),
519-
}
516+
_ => ((res, None)),
517+
});
520518
} else if ns == MacroNS {
521519
return Err(UnresolvedPath {
522520
item_id,

0 commit comments

Comments
 (0)