@@ -2268,7 +2268,11 @@ fn render_impl_summary(
22682268) -> impl fmt:: Display {
22692269 fmt:: from_fn ( move |w| {
22702270 let inner_impl = i. inner_impl ( ) ;
2271- let id = cx. derive_id ( get_id_for_impl ( cx. tcx ( ) , i. impl_item . item_id ) ) ;
2271+ let id = cx. derive_id ( get_id_for_impl (
2272+ cx. tcx ( ) ,
2273+ i. impl_item . item_id ,
2274+ inner_impl. trait_ . is_some ( ) ,
2275+ ) ) ;
22722276 let aliases = ( !aliases. is_empty ( ) )
22732277 . then_some ( fmt:: from_fn ( |f| {
22742278 write ! ( f, " data-aliases=\" {}\" " , fmt:: from_fn( |f| aliases. iter( ) . joined( "," , f) ) )
@@ -2395,16 +2399,16 @@ pub(crate) fn small_url_encode(s: String) -> String {
23952399 }
23962400}
23972401
2398- fn get_id_for_impl ( tcx : TyCtxt < ' _ > , impl_id : ItemId ) -> String {
2402+ fn get_id_for_impl ( tcx : TyCtxt < ' _ > , impl_id : ItemId , is_of_trait : bool ) -> String {
23992403 use rustc_middle:: ty:: print:: with_forced_trimmed_paths;
24002404 let ( type_, trait_) = match impl_id {
24012405 ItemId :: Auto { trait_, for_ } => {
24022406 let ty = tcx. type_of ( for_) . skip_binder ( ) ;
24032407 ( ty, Some ( ty:: TraitRef :: new ( tcx, trait_, [ ty] ) ) )
24042408 }
24052409 ItemId :: Blanket { impl_id, .. } | ItemId :: DefId ( impl_id) => {
2406- if let Some ( trait_ref ) = tcx . impl_opt_trait_ref ( impl_id ) {
2407- let trait_ref = trait_ref . skip_binder ( ) ;
2410+ if is_of_trait {
2411+ let trait_ref = tcx . impl_trait_ref ( impl_id ) . skip_binder ( ) ;
24082412 ( trait_ref. self_ty ( ) , Some ( trait_ref) )
24092413 } else {
24102414 ( tcx. type_of ( impl_id) . skip_binder ( ) , None )
@@ -2423,7 +2427,10 @@ fn extract_for_impl_name(item: &clean::Item, cx: &Context<'_>) -> Option<(String
24232427 clean:: ItemKind :: ImplItem ( ref i) if i. trait_ . is_some ( ) => {
24242428 // Alternative format produces no URLs,
24252429 // so this parameter does nothing.
2426- Some ( ( format ! ( "{:#}" , i. for_. print( cx) ) , get_id_for_impl ( cx. tcx ( ) , item. item_id ) ) )
2430+ Some ( (
2431+ format ! ( "{:#}" , i. for_. print( cx) ) ,
2432+ get_id_for_impl ( cx. tcx ( ) , item. item_id , i. trait_ . is_some ( ) ) ,
2433+ ) )
24272434 }
24282435 _ => None ,
24292436 }
0 commit comments