Skip to content

Commit

Permalink
fix links from trait impl methods to trait declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Apr 13, 2021
1 parent 5c13042 commit e1b6bb2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,9 @@ fn render_assoc_item(
let cache = cx.cache();
let tcx = cx.tcx();
let name = meth.name.as_ref().unwrap();
let anchor = format!("#{}.{}", meth.type_(), name);
let href = match link {
AssocItemLink::Anchor(Some(ref id)) => format!("#{}", id),
AssocItemLink::Anchor(None) => anchor,
AssocItemLink::Anchor(None) => format!("#{}.{}", meth.type_(), name),
AssocItemLink::GotoSource(did, provided_methods) => {
// We're creating a link from an impl-item to the corresponding
// trait-item and need to map the anchored type accordingly.
Expand All @@ -925,7 +924,9 @@ fn render_assoc_item(
ItemType::TyMethod
};

href(did, cache).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
href(did, cache)
.map(|p| format!("{}#{}.{}", p.0, ty, name))
.unwrap_or_else(|| format!("#{}.{}", ty, name))
}
};
let vis = meth.visibility.print_with_space(tcx, meth.def_id, cache).to_string();
Expand Down

0 comments on commit e1b6bb2

Please sign in to comment.