@@ -74,7 +74,7 @@ use crate::html::format::{
74
74
PrintWithSpace ,
75
75
} ;
76
76
use crate :: html:: highlight;
77
- use crate :: html:: markdown:: { HeadingOffset , Markdown , MarkdownHtml , MarkdownSummaryLine } ;
77
+ use crate :: html:: markdown:: { HeadingOffset , IdMap , Markdown , MarkdownHtml , MarkdownSummaryLine } ;
78
78
use crate :: html:: sources;
79
79
use crate :: scrape_examples:: { CallData , CallLocation } ;
80
80
use crate :: try_none;
@@ -1950,8 +1950,10 @@ fn small_url_encode(s: String) -> String {
1950
1950
fn sidebar_assoc_items ( cx : & Context < ' _ > , out : & mut Buffer , it : & clean:: Item ) {
1951
1951
let did = it. def_id . expect_def_id ( ) ;
1952
1952
let cache = cx. cache ( ) ;
1953
+
1953
1954
if let Some ( v) = cache. impls . get ( & did) {
1954
1955
let mut used_links = FxHashSet :: default ( ) ;
1956
+ let mut id_map = IdMap :: new ( ) ;
1955
1957
1956
1958
{
1957
1959
let used_links_bor = & mut used_links;
@@ -1992,7 +1994,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
1992
1994
sidebar_deref_methods ( cx, out, impl_, v, & mut derefs) ;
1993
1995
}
1994
1996
1995
- let format_impls = |impls : Vec < & Impl > | {
1997
+ let format_impls = |impls : Vec < & Impl > , id_map : & mut IdMap | {
1996
1998
let mut links = FxHashSet :: default ( ) ;
1997
1999
1998
2000
let mut ret = impls
@@ -2001,13 +2003,14 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
2001
2003
if let Some ( ref i) = it. inner_impl ( ) . trait_ {
2002
2004
let i_display = format ! ( "{:#}" , i. print( cx) ) ;
2003
2005
let out = Escape ( & i_display) ;
2004
- let encoded = small_url_encode ( format ! ( "{:#}" , i. print( cx) ) ) ;
2006
+ let encoded =
2007
+ id_map. derive ( small_url_encode ( format ! ( "impl-{:#}" , i. print( cx) ) ) ) ;
2005
2008
let prefix = match it. inner_impl ( ) . polarity {
2006
2009
ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
2007
2010
ty:: ImplPolarity :: Negative => "!" ,
2008
2011
} ;
2009
2012
let generated =
2010
- format ! ( "<a href=\" #impl- {}\" >{}{}</a>" , encoded, prefix, out) ;
2013
+ format ! ( "<a href=\" #{}\" >{}{}</a>" , encoded, prefix, out) ;
2011
2014
if links. insert ( generated. clone ( ) ) { Some ( generated) } else { None }
2012
2015
} else {
2013
2016
None
@@ -2023,9 +2026,9 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
2023
2026
let ( blanket_impl, concrete) : ( Vec < & Impl > , Vec < & Impl > ) =
2024
2027
concrete. into_iter ( ) . partition :: < Vec < _ > , _ > ( |i| i. inner_impl ( ) . kind . is_blanket ( ) ) ;
2025
2028
2026
- let concrete_format = format_impls ( concrete) ;
2027
- let synthetic_format = format_impls ( synthetic) ;
2028
- let blanket_format = format_impls ( blanket_impl) ;
2029
+ let concrete_format = format_impls ( concrete, & mut id_map ) ;
2030
+ let synthetic_format = format_impls ( synthetic, & mut id_map ) ;
2031
+ let blanket_format = format_impls ( blanket_impl, & mut id_map ) ;
2029
2032
2030
2033
if !concrete_format. is_empty ( ) {
2031
2034
print_sidebar_block (
0 commit comments