@@ -634,7 +634,6 @@ fn render_impls(
634
634
& [ ] ,
635
635
ImplRenderingParameters {
636
636
show_def_docs : true ,
637
- is_on_foreign_type : false ,
638
637
show_default_items : true ,
639
638
show_non_assoc_items : true ,
640
639
toggle_open_by_default,
@@ -1071,7 +1070,6 @@ fn render_assoc_items_inner(
1071
1070
& [ ] ,
1072
1071
ImplRenderingParameters {
1073
1072
show_def_docs : true ,
1074
- is_on_foreign_type : false ,
1075
1073
show_default_items : true ,
1076
1074
show_non_assoc_items : true ,
1077
1075
toggle_open_by_default : true ,
@@ -1287,7 +1285,6 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
1287
1285
#[ derive( Clone , Copy , Debug ) ]
1288
1286
struct ImplRenderingParameters {
1289
1287
show_def_docs : bool ,
1290
- is_on_foreign_type : bool ,
1291
1288
show_default_items : bool ,
1292
1289
/// Whether or not to show methods.
1293
1290
show_non_assoc_items : bool ,
@@ -1603,7 +1600,6 @@ fn render_impl(
1603
1600
parent,
1604
1601
rendering_params. show_def_docs ,
1605
1602
use_absolute,
1606
- rendering_params. is_on_foreign_type ,
1607
1603
aliases,
1608
1604
) ;
1609
1605
if toggled {
@@ -1688,21 +1684,12 @@ pub(crate) fn render_impl_summary(
1688
1684
containing_item : & clean:: Item ,
1689
1685
show_def_docs : bool ,
1690
1686
use_absolute : Option < bool > ,
1691
- is_on_foreign_type : bool ,
1692
1687
// This argument is used to reference same type with different paths to avoid duplication
1693
1688
// in documentation pages for trait with automatic implementations like "Send" and "Sync".
1694
1689
aliases : & [ String ] ,
1695
1690
) {
1696
- let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
1697
- Some ( ref t) => {
1698
- if is_on_foreign_type {
1699
- get_id_for_impl_on_foreign_type ( & i. inner_impl ( ) . for_ , t, cx)
1700
- } else {
1701
- format ! ( "impl-{}" , small_url_encode( format!( "{:#}" , t. print( cx) ) ) )
1702
- }
1703
- }
1704
- None => "impl" . to_string ( ) ,
1705
- } ) ;
1691
+ let id =
1692
+ cx. derive_id ( get_id_for_impl ( & i. inner_impl ( ) . for_ , i. inner_impl ( ) . trait_ . as_ref ( ) , cx) ) ;
1706
1693
let aliases = if aliases. is_empty ( ) {
1707
1694
String :: new ( )
1708
1695
} else {
@@ -1986,21 +1973,18 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
1986
1973
let mut ret = impls
1987
1974
. iter ( )
1988
1975
. filter_map ( |it| {
1989
- if let Some ( ref i) = it. inner_impl ( ) . trait_ {
1990
- let i_display = format ! ( "{:#}" , i. print( cx) ) ;
1991
- let out = Escape ( & i_display) ;
1992
- let encoded =
1993
- id_map. derive ( small_url_encode ( format ! ( "impl-{:#}" , i. print( cx) ) ) ) ;
1994
- let prefix = match it. inner_impl ( ) . polarity {
1995
- ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
1996
- ty:: ImplPolarity :: Negative => "!" ,
1997
- } ;
1998
- let generated =
1999
- format ! ( "<a href=\" #{}\" >{}{}</a>" , encoded, prefix, out) ;
2000
- if links. insert ( generated. clone ( ) ) { Some ( generated) } else { None }
2001
- } else {
2002
- None
2003
- }
1976
+ let trait_ = it. inner_impl ( ) . trait_ . as_ref ( ) ?;
1977
+ let encoded =
1978
+ id_map. derive ( get_id_for_impl ( & it. inner_impl ( ) . for_ , Some ( trait_) , cx) ) ;
1979
+
1980
+ let i_display = format ! ( "{:#}" , trait_. print( cx) ) ;
1981
+ let out = Escape ( & i_display) ;
1982
+ let prefix = match it. inner_impl ( ) . polarity {
1983
+ ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
1984
+ ty:: ImplPolarity :: Negative => "!" ,
1985
+ } ;
1986
+ let generated = format ! ( "<a href=\" #{}\" >{}{}</a>" , encoded, prefix, out) ;
1987
+ if links. insert ( generated. clone ( ) ) { Some ( generated) } else { None }
2004
1988
} )
2005
1989
. collect :: < Vec < String > > ( ) ;
2006
1990
ret. sort ( ) ;
@@ -2147,12 +2131,11 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
2147
2131
}
2148
2132
}
2149
2133
2150
- fn get_id_for_impl_on_foreign_type (
2151
- for_ : & clean:: Type ,
2152
- trait_ : & clean:: Path ,
2153
- cx : & Context < ' _ > ,
2154
- ) -> String {
2155
- small_url_encode ( format ! ( "impl-{:#}-for-{:#}" , trait_. print( cx) , for_. print( cx) ) )
2134
+ fn get_id_for_impl ( for_ : & clean:: Type , trait_ : Option < & clean:: Path > , cx : & Context < ' _ > ) -> String {
2135
+ match trait_ {
2136
+ Some ( t) => small_url_encode ( format ! ( "impl-{:#}-for-{:#}" , t. print( cx) , for_. print( cx) ) ) ,
2137
+ None => small_url_encode ( format ! ( "impl-{:#}" , for_. print( cx) ) ) ,
2138
+ }
2156
2139
}
2157
2140
2158
2141
fn extract_for_impl_name ( item : & clean:: Item , cx : & Context < ' _ > ) -> Option < ( String , String ) > {
@@ -2161,10 +2144,7 @@ fn extract_for_impl_name(item: &clean::Item, cx: &Context<'_>) -> Option<(String
2161
2144
i. trait_ . as_ref ( ) . map ( |trait_| {
2162
2145
// Alternative format produces no URLs,
2163
2146
// so this parameter does nothing.
2164
- (
2165
- format ! ( "{:#}" , i. for_. print( cx) ) ,
2166
- get_id_for_impl_on_foreign_type ( & i. for_ , trait_, cx) ,
2167
- )
2147
+ ( format ! ( "{:#}" , i. for_. print( cx) ) , get_id_for_impl ( & i. for_ , Some ( trait_) , cx) )
2168
2148
} )
2169
2149
}
2170
2150
_ => None ,
0 commit comments