File tree Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -1681,6 +1681,21 @@ impl Type {
16811681 _ => false
16821682 }
16831683 }
1684+
1685+ pub fn generics ( & self ) -> Option < & [ Type ] > {
1686+ match * self {
1687+ ResolvedPath { ref path, .. } => {
1688+ path. segments . last ( ) . and_then ( |seg| {
1689+ if let PathParameters :: AngleBracketed { ref types, .. } = seg. params {
1690+ Some ( & * * types)
1691+ } else {
1692+ None
1693+ }
1694+ } )
1695+ }
1696+ _ => None ,
1697+ }
1698+ }
16841699}
16851700
16861701impl GetDefId for Type {
Original file line number Diff line number Diff line change @@ -1306,7 +1306,8 @@ impl DocFolder for Cache {
13061306 // Figure out the id of this impl. This may map to a
13071307 // primitive rather than always to a struct/enum.
13081308 // Note: matching twice to restrict the lifetime of the `i` borrow.
1309- let did = if let clean:: Item { inner : clean:: ImplItem ( ref i) , .. } = item {
1309+ let mut dids = vec ! [ ] ;
1310+ if let clean:: Item { inner : clean:: ImplItem ( ref i) , .. } = item {
13101311 let masked_trait = i. trait_ . def_id ( ) . map_or ( false ,
13111312 |d| self . masked_crates . contains ( & d. krate ) ) ;
13121313 if !masked_trait {
@@ -1315,23 +1316,33 @@ impl DocFolder for Cache {
13151316 clean:: BorrowedRef {
13161317 type_ : box clean:: ResolvedPath { did, .. } , ..
13171318 } => {
1318- Some ( did)
1319+ dids . push ( did) ;
13191320 }
13201321 ref t => {
1321- t. primitive_type ( ) . and_then ( |t| {
1322+ let did = t. primitive_type ( ) . and_then ( |t| {
13221323 self . primitive_locations . get ( & t) . cloned ( )
1323- } )
1324+ } ) ;
1325+
1326+ if let Some ( did) = did {
1327+ dids. push ( did) ;
1328+ }
1329+ }
1330+ }
1331+ }
1332+
1333+ if let Some ( generics) = i. trait_ . as_ref ( ) . and_then ( |t| t. generics ( ) ) {
1334+ for bound in generics {
1335+ if let Some ( did) = bound. def_id ( ) {
1336+ dids. push ( did) ;
13241337 }
13251338 }
1326- } else {
1327- None
13281339 }
13291340 } else {
13301341 unreachable ! ( )
13311342 } ;
1332- if let Some ( did) = did {
1343+ for did in dids {
13331344 self . impls . entry ( did) . or_insert ( vec ! [ ] ) . push ( Impl {
1334- impl_item : item,
1345+ impl_item : item. clone ( ) ,
13351346 } ) ;
13361347 }
13371348 None
You can’t perform that action at this time.
0 commit comments