File tree 2 files changed +7
-15
lines changed 2 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -249,11 +249,13 @@ impl Cursor {
249
249
/// Given that this cursor's referent is a reference to another type, or is
250
250
/// a declaration, get the cursor pointing to the referenced type or type of
251
251
/// the declared thing.
252
- pub fn definition ( & self ) -> Cursor {
252
+ pub fn definition ( & self ) -> Option < Cursor > {
253
253
unsafe {
254
- Cursor {
254
+ let ret = Cursor {
255
255
x : clang_getCursorDefinition ( self . x ) ,
256
- }
256
+ } ;
257
+
258
+ if ret. is_valid ( ) { Some ( ret) } else { None }
257
259
}
258
260
}
259
261
Original file line number Diff line number Diff line change @@ -801,12 +801,7 @@ impl ClangItemParser for Item {
801
801
// Types are sort of special, so to avoid parsing template classes
802
802
// twice, handle them separately.
803
803
{
804
- let definition = cursor. definition ( ) ;
805
- let applicable_cursor = if definition. is_valid ( ) {
806
- definition
807
- } else {
808
- cursor
809
- } ;
804
+ let applicable_cursor = cursor. definition ( ) . unwrap_or ( cursor) ;
810
805
match Self :: from_ty ( & applicable_cursor. cur_type ( ) ,
811
806
Some ( applicable_cursor) ,
812
807
parent_id,
@@ -937,12 +932,7 @@ impl ClangItemParser for Item {
937
932
938
933
let decl = {
939
934
let decl = ty. declaration ( ) ;
940
- let definition = decl. definition ( ) ;
941
- if definition. is_valid ( ) {
942
- definition
943
- } else {
944
- decl
945
- }
935
+ decl. definition ( ) . unwrap_or ( decl)
946
936
} ;
947
937
948
938
let comment = decl. raw_comment ( )
You can’t perform that action at this time.
0 commit comments