File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -263,11 +263,13 @@ impl Cursor {
263263
264264 /// Given that this cursor's referent is reference type, get the cursor
265265 /// pointing to the referenced type.
266- pub fn referenced ( & self ) -> Cursor {
266+ pub fn referenced ( & self ) -> Option < Cursor > {
267267 unsafe {
268- Cursor {
268+ let ret = Cursor {
269269 x : clang_getCursorReferenced ( self . x ) ,
270- }
270+ } ;
271+
272+ if ret. is_valid ( ) { Some ( ret) } else { None }
271273 }
272274 }
273275
Original file line number Diff line number Diff line change @@ -612,7 +612,7 @@ impl Type {
612612 TypeKind :: TemplateAlias ( inner. unwrap ( ) , args)
613613 }
614614 CXCursor_TemplateRef => {
615- let referenced = location. referenced ( ) ;
615+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
616616 let referenced_ty = referenced. cur_type ( ) ;
617617 let referenced_declaration =
618618 Some ( referenced_ty. declaration ( ) ) ;
@@ -624,7 +624,7 @@ impl Type {
624624 ctx) ;
625625 }
626626 CXCursor_TypeRef => {
627- let referenced = location. referenced ( ) ;
627+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
628628 let referenced_ty = referenced. cur_type ( ) ;
629629 let referenced_declaration =
630630 Some ( referenced_ty. declaration ( ) ) ;
You can’t perform that action at this time.
0 commit comments