File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -505,9 +505,15 @@ impl<'ctx> BindgenContext<'ctx> {
505
505
found_invalid_template_ref = true ;
506
506
}
507
507
if c. kind ( ) == CXCursor_TypeRef {
508
+ // The `with_id` id will potentially end up unused if we give up
509
+ // on this type (for example, its a tricky partial template
510
+ // specialization), so if we pass `with_id` as the parent, it is
511
+ // potentially a dangling reference. Instead, use the canonical
512
+ // template declaration as the parent. It is already parsed and
513
+ // has a known-resolvable `ItemId`.
508
514
let new_ty = Item :: from_ty_or_ref ( c. cur_type ( ) ,
509
515
Some ( c) ,
510
- Some ( with_id ) ,
516
+ Some ( wrapping ) ,
511
517
self ) ;
512
518
args. push ( new_ty) ;
513
519
}
Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ impl ItemId {
88
88
/// Allocate the next `ItemId`.
89
89
pub fn next ( ) -> Self {
90
90
static NEXT_ITEM_ID : AtomicUsize = ATOMIC_USIZE_INIT ;
91
- ItemId ( NEXT_ITEM_ID . fetch_add ( 1 , Ordering :: Relaxed ) )
91
+ let next_id = NEXT_ITEM_ID . fetch_add ( 1 , Ordering :: Relaxed ) ;
92
+ ItemId ( next_id)
92
93
}
93
94
}
94
95
You can’t perform that action at this time.
0 commit comments