File tree 3 files changed +33
-18
lines changed 3 files changed +33
-18
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ impl<'ctx> BindgenContext<'ctx> {
299
299
let id = item. id ( ) ;
300
300
let is_type = item. kind ( ) . is_type ( ) ;
301
301
let is_unnamed = is_type && item. expect_type ( ) . name ( ) . is_none ( ) ;
302
+ let is_template_instantiation =
303
+ is_type && item. expect_type ( ) . is_template_instantiation ( ) ;
302
304
303
305
// Be sure to track all the generated children under namespace, even
304
306
// those generated after resolving typerefs, etc.
@@ -317,7 +319,7 @@ impl<'ctx> BindgenContext<'ctx> {
317
319
// Unnamed items can have an USR, but they can't be referenced from
318
320
// other sites explicitly and the USR can match if the unnamed items are
319
321
// nested, so don't bother tracking them.
320
- if is_type && declaration. is_some ( ) {
322
+ if is_type && !is_template_instantiation && declaration. is_some ( ) {
321
323
let mut declaration = declaration. unwrap ( ) ;
322
324
if !declaration. is_valid ( ) {
323
325
if let Some ( location) = location {
Original file line number Diff line number Diff line change @@ -240,25 +240,30 @@ impl TemplateInstantiation {
240
240
. collect ( )
241
241
} ) ;
242
242
243
- let definition = ty. declaration ( )
244
- . specialized ( )
245
- . or_else ( || {
246
- let mut template_ref = None ;
247
- ty. declaration ( ) . visit ( |child| {
248
- if child. kind ( ) == CXCursor_TemplateRef {
249
- template_ref = Some ( child) ;
250
- return CXVisit_Break ;
251
- }
243
+ let declaration = ty. declaration ( ) ;
244
+ let definition = if declaration. kind ( ) == CXCursor_TypeAliasTemplateDecl {
245
+ Some ( declaration)
246
+ } else {
247
+ declaration
248
+ . specialized ( )
249
+ . or_else ( || {
250
+ let mut template_ref = None ;
251
+ ty. declaration ( ) . visit ( |child| {
252
+ if child. kind ( ) == CXCursor_TemplateRef {
253
+ template_ref = Some ( child) ;
254
+ return CXVisit_Break ;
255
+ }
252
256
253
- // Instantiations of template aliases might have the
254
- // TemplateRef to the template alias definition arbitrarily
255
- // deep, so we need to recurse here and not only visit
256
- // direct children.
257
- CXChildVisit_Recurse
258
- } ) ;
257
+ // Instantiations of template aliases might have the
258
+ // TemplateRef to the template alias definition arbitrarily
259
+ // deep, so we need to recurse here and not only visit
260
+ // direct children.
261
+ CXChildVisit_Recurse
262
+ } ) ;
259
263
260
- template_ref. and_then ( |cur| cur. referenced ( ) )
261
- } ) ;
264
+ template_ref. and_then ( |cur| cur. referenced ( ) )
265
+ } )
266
+ } ;
262
267
263
268
let definition = match definition {
264
269
Some ( def) => def,
Original file line number Diff line number Diff line change @@ -109,6 +109,14 @@ impl Type {
109
109
}
110
110
}
111
111
112
+ /// Is this a template instantiation type?
113
+ pub fn is_template_instantiation ( & self ) -> bool {
114
+ match self . kind {
115
+ TypeKind :: TemplateInstantiation ( ..) => true ,
116
+ _ => false ,
117
+ }
118
+ }
119
+
112
120
/// Is this a template alias type?
113
121
pub fn is_template_alias ( & self ) -> bool {
114
122
match self . kind {
You can’t perform that action at this time.
0 commit comments