@@ -352,14 +352,22 @@ pub fn build_impl(
352
352
}
353
353
}
354
354
355
- let for_ = if let Some ( did) = did. as_local ( ) {
356
- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( did) ;
357
- match tcx. hir ( ) . expect_item ( hir_id) . kind {
358
- hir:: ItemKind :: Impl { self_ty, .. } => self_ty. clean ( cx) ,
359
- _ => panic ! ( "did given to build_impl was not an impl" ) ,
355
+ let impl_item = match did. as_local ( ) {
356
+ Some ( did) => {
357
+ let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( did) ;
358
+ match tcx. hir ( ) . expect_item ( hir_id) . kind {
359
+ hir:: ItemKind :: Impl { self_ty, ref generics, ref items, .. } => {
360
+ Some ( ( self_ty, generics, items) )
361
+ }
362
+ _ => panic ! ( "`DefID` passed to `build_impl` is not an `impl" ) ,
363
+ }
360
364
}
361
- } else {
362
- tcx. type_of ( did) . clean ( cx)
365
+ None => None ,
366
+ } ;
367
+
368
+ let for_ = match impl_item {
369
+ Some ( ( self_ty, _, _) ) => self_ty. clean ( cx) ,
370
+ None => tcx. type_of ( did) . clean ( cx) ,
363
371
} ;
364
372
365
373
// Only inline impl if the implementing type is
@@ -379,17 +387,12 @@ pub fn build_impl(
379
387
}
380
388
381
389
let predicates = tcx. explicit_predicates_of ( did) ;
382
- let ( trait_items, generics) = if let Some ( did) = did. as_local ( ) {
383
- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( did) ;
384
- match tcx. hir ( ) . expect_item ( hir_id) . kind {
385
- hir:: ItemKind :: Impl { ref generics, ref items, .. } => (
386
- items. iter ( ) . map ( |item| tcx. hir ( ) . impl_item ( item. id ) . clean ( cx) ) . collect :: < Vec < _ > > ( ) ,
387
- generics. clean ( cx) ,
388
- ) ,
389
- _ => panic ! ( "did given to build_impl was not an impl" ) ,
390
- }
391
- } else {
392
- (
390
+ let ( trait_items, generics) = match impl_item {
391
+ Some ( ( _, generics, items) ) => (
392
+ items. iter ( ) . map ( |item| tcx. hir ( ) . impl_item ( item. id ) . clean ( cx) ) . collect :: < Vec < _ > > ( ) ,
393
+ generics. clean ( cx) ,
394
+ ) ,
395
+ None => (
393
396
tcx. associated_items ( did)
394
397
. in_definition_order ( )
395
398
. filter_map ( |item| {
@@ -401,7 +404,7 @@ pub fn build_impl(
401
404
} )
402
405
. collect :: < Vec < _ > > ( ) ,
403
406
clean:: enter_impl_trait ( cx, || ( tcx. generics_of ( did) , predicates) . clean ( cx) ) ,
404
- )
407
+ ) ,
405
408
} ;
406
409
let polarity = tcx. impl_polarity ( did) ;
407
410
let trait_ = associated_trait. clean ( cx) . map ( |bound| match bound {
0 commit comments