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 @@ -264,11 +264,13 @@ impl Cursor {
264264
265265 /// Given that this cursor's referent is reference type, get the cursor
266266 /// pointing to the referenced type.
267- pub fn referenced ( & self ) -> Cursor {
267+ pub fn referenced ( & self ) -> Option < Cursor > {
268268 unsafe {
269- Cursor {
269+ let ret = Cursor {
270270 x : clang_getCursorReferenced ( self . x ) ,
271- }
271+ } ;
272+
273+ if ret. is_valid ( ) { Some ( ret) } else { None }
272274 }
273275 }
274276
Original file line number Diff line number Diff line change @@ -667,7 +667,7 @@ impl Type {
667667 TypeKind :: TemplateAlias ( inner. unwrap ( ) , args)
668668 }
669669 CXCursor_TemplateRef => {
670- let referenced = location. referenced ( ) ;
670+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
671671 let referenced_ty = referenced. cur_type ( ) ;
672672 let referenced_declaration =
673673 Some ( referenced_ty. declaration ( ) ) ;
@@ -679,7 +679,7 @@ impl Type {
679679 ctx) ;
680680 }
681681 CXCursor_TypeRef => {
682- let referenced = location. referenced ( ) ;
682+ let referenced = location. referenced ( ) . expect ( "expected value, got none" ) ;
683683 let referenced_ty = referenced. cur_type ( ) ;
684684 let referenced_declaration =
685685 Some ( referenced_ty. declaration ( ) ) ;
You can’t perform that action at this time.
0 commit comments