File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -264,11 +264,13 @@ impl Cursor {
264
264
265
265
/// Given that this cursor's referent is reference type, get the cursor
266
266
/// pointing to the referenced type.
267
- pub fn referenced ( & self ) -> Cursor {
267
+ pub fn referenced ( & self ) -> Option < Cursor > {
268
268
unsafe {
269
- Cursor {
269
+ let ret = Cursor {
270
270
x : clang_getCursorReferenced ( self . x ) ,
271
- }
271
+ } ;
272
+
273
+ if ret. is_valid ( ) { Some ( ret) } else { None }
272
274
}
273
275
}
274
276
Original file line number Diff line number Diff line change @@ -667,7 +667,7 @@ impl Type {
667
667
TypeKind :: TemplateAlias ( inner. unwrap ( ) , args)
668
668
}
669
669
CXCursor_TemplateRef => {
670
- let referenced = location. referenced ( ) ;
670
+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
671
671
let referenced_ty = referenced. cur_type ( ) ;
672
672
let referenced_declaration =
673
673
Some ( referenced_ty. declaration ( ) ) ;
@@ -679,7 +679,7 @@ impl Type {
679
679
ctx) ;
680
680
}
681
681
CXCursor_TypeRef => {
682
- let referenced = location. referenced ( ) ;
682
+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
683
683
let referenced_ty = referenced. cur_type ( ) ;
684
684
let referenced_declaration =
685
685
Some ( referenced_ty. declaration ( ) ) ;
You can’t perform that action at this time.
0 commit comments