@@ -2692,27 +2692,40 @@ impl ItemResolver {
2692
2692
2693
2693
/// Finish configuring and perform the actual item resolution.
2694
2694
pub fn resolve ( self , ctx : & BindgenContext ) -> & Item {
2695
+ match self . resolve_fallible ( ctx) {
2696
+ Some ( item) => item,
2697
+ None => panic ! ( "Not an item: {:?}" , self . id) ,
2698
+ }
2699
+ }
2700
+
2701
+ /// Finish configuring and perform the actual item resolution.
2702
+ pub fn resolve_fallible ( self , ctx : & BindgenContext ) -> Option < & Item > {
2695
2703
assert ! ( ctx. collected_typerefs( ) ) ;
2696
2704
2697
2705
let mut id = self . id ;
2698
2706
loop {
2699
- let item = ctx. resolve_item ( id) ;
2700
- let ty_kind = item. as_type ( ) . map ( |t| t. kind ( ) ) ;
2701
- match ty_kind {
2702
- Some ( & TypeKind :: ResolvedTypeRef ( next_id) )
2703
- if self . through_type_refs =>
2704
- {
2705
- id = next_id. into ( ) ;
2706
- }
2707
- // We intentionally ignore template aliases here, as they are
2708
- // more complicated, and don't represent a simple renaming of
2709
- // some type.
2710
- Some ( & TypeKind :: Alias ( next_id) )
2711
- if self . through_type_aliases =>
2712
- {
2713
- id = next_id. into ( ) ;
2707
+ let item = ctx. resolve_item_fallible ( id) ;
2708
+ match item {
2709
+ None => return None ,
2710
+ Some ( item) => {
2711
+ let ty_kind = item. as_type ( ) . map ( |t| t. kind ( ) ) ;
2712
+ match ty_kind {
2713
+ Some ( & TypeKind :: ResolvedTypeRef ( next_id) )
2714
+ if self . through_type_refs =>
2715
+ {
2716
+ id = next_id. into ( ) ;
2717
+ }
2718
+ // We intentionally ignore template aliases here, as they are
2719
+ // more complicated, and don't represent a simple renaming of
2720
+ // some type.
2721
+ Some ( & TypeKind :: Alias ( next_id) )
2722
+ if self . through_type_aliases =>
2723
+ {
2724
+ id = next_id. into ( ) ;
2725
+ }
2726
+ _ => return Some ( item) ,
2727
+ }
2714
2728
}
2715
- _ => return item,
2716
2729
}
2717
2730
}
2718
2731
}
0 commit comments