File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ impl Cursor {
187
187
188
188
/// Is the referent a template specialization?
189
189
pub fn is_template ( & self ) -> bool {
190
- self . specialized ( ) . is_valid ( )
190
+ self . specialized ( ) . map_or ( false , |c| c . is_valid ( ) )
191
191
}
192
192
193
193
/// Is the referent a fully specialized template specialization without any
@@ -287,11 +287,15 @@ impl Cursor {
287
287
288
288
/// Given that this cursor points to a template specialization, get a cursor
289
289
/// pointing to the template definition that is being specialized.
290
- pub fn specialized ( & self ) -> Cursor {
290
+ pub fn specialized ( & self ) -> Option < Cursor > {
291
+ if !self . is_valid ( ) {
292
+ return None ;
293
+ }
294
+
291
295
unsafe {
292
- Cursor {
296
+ Some ( Cursor {
293
297
x : clang_getSpecializedCursorTemplate ( self . x ) ,
294
- }
298
+ } )
295
299
}
296
300
}
297
301
Original file line number Diff line number Diff line change @@ -512,7 +512,8 @@ impl CompInfo {
512
512
}
513
513
} ;
514
514
515
- ci. ref_template = Item :: parse ( cursor. specialized ( ) , None , ctx) . ok ( ) ;
515
+ ci. ref_template = cursor. specialized ( )
516
+ . and_then ( |c| Item :: parse ( c, None , ctx) . ok ( ) ) ;
516
517
517
518
let mut maybe_anonymous_struct_field = None ;
518
519
cursor. visit ( |cur, _other| {
You can’t perform that action at this time.
0 commit comments