File tree 2 files changed +34
-8
lines changed
2 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -1681,6 +1681,21 @@ impl Type {
1681
1681
_ => false
1682
1682
}
1683
1683
}
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
+ }
1684
1699
}
1685
1700
1686
1701
impl GetDefId for Type {
Original file line number Diff line number Diff line change @@ -1306,7 +1306,8 @@ impl DocFolder for Cache {
1306
1306
// Figure out the id of this impl. This may map to a
1307
1307
// primitive rather than always to a struct/enum.
1308
1308
// 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 {
1310
1311
let masked_trait = i. trait_ . def_id ( ) . map_or ( false ,
1311
1312
|d| self . masked_crates . contains ( & d. krate ) ) ;
1312
1313
if !masked_trait {
@@ -1315,23 +1316,33 @@ impl DocFolder for Cache {
1315
1316
clean:: BorrowedRef {
1316
1317
type_ : box clean:: ResolvedPath { did, .. } , ..
1317
1318
} => {
1318
- Some ( did)
1319
+ dids . push ( did) ;
1319
1320
}
1320
1321
ref t => {
1321
- t. primitive_type ( ) . and_then ( |t| {
1322
+ let did = t. primitive_type ( ) . and_then ( |t| {
1322
1323
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) ;
1324
1337
}
1325
1338
}
1326
- } else {
1327
- None
1328
1339
}
1329
1340
} else {
1330
1341
unreachable ! ( )
1331
1342
} ;
1332
- if let Some ( did) = did {
1343
+ for did in dids {
1333
1344
self . impls . entry ( did) . or_insert ( vec ! [ ] ) . push ( Impl {
1334
- impl_item : item,
1345
+ impl_item : item. clone ( ) ,
1335
1346
} ) ;
1336
1347
}
1337
1348
None
You can’t perform that action at this time.
0 commit comments