Skip to content

Commit e1b6bb2

Browse files
committed
fix links from trait impl methods to trait declaration
1 parent 5c13042 commit e1b6bb2

File tree

1 file changed

+4
-3
lines changed
  • src/librustdoc/html/render

1 file changed

+4
-3
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,9 @@ fn render_assoc_item(
912912
let cache = cx.cache();
913913
let tcx = cx.tcx();
914914
let name = meth.name.as_ref().unwrap();
915-
let anchor = format!("#{}.{}", meth.type_(), name);
916915
let href = match link {
917916
AssocItemLink::Anchor(Some(ref id)) => format!("#{}", id),
918-
AssocItemLink::Anchor(None) => anchor,
917+
AssocItemLink::Anchor(None) => format!("#{}.{}", meth.type_(), name),
919918
AssocItemLink::GotoSource(did, provided_methods) => {
920919
// We're creating a link from an impl-item to the corresponding
921920
// trait-item and need to map the anchored type accordingly.
@@ -925,7 +924,9 @@ fn render_assoc_item(
925924
ItemType::TyMethod
926925
};
927926

928-
href(did, cache).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
927+
href(did, cache)
928+
.map(|p| format!("{}#{}.{}", p.0, ty, name))
929+
.unwrap_or_else(|| format!("#{}.{}", ty, name))
929930
}
930931
};
931932
let vis = meth.visibility.print_with_space(tcx, meth.def_id, cache).to_string();

0 commit comments

Comments
 (0)