@@ -237,7 +237,10 @@ pub struct CompInfo {
237
237
/// around the template arguments.
238
238
detect_has_destructor_cycle : Cell < bool > ,
239
239
240
- is_declaration : bool ,
240
+ /// Used to indicate when a struct has been forward declared. Usually used
241
+ /// in headers so that APIs can't modify them directly.
242
+ /// e.g: struct forward_declared_struct;
243
+ is_forward_declaration : bool ,
241
244
}
242
245
243
246
impl CompInfo {
@@ -262,7 +265,7 @@ impl CompInfo {
262
265
found_unknown_attr : false ,
263
266
detect_derive_debug_cycle : Cell :: new ( false ) ,
264
267
detect_has_destructor_cycle : Cell :: new ( false ) ,
265
- is_declaration : false ,
268
+ is_forward_declaration : false ,
266
269
}
267
270
}
268
271
@@ -509,7 +512,8 @@ impl CompInfo {
509
512
debug ! ( "CompInfo::from_ty({:?}, {:?})" , kind, cursor) ;
510
513
511
514
let mut ci = CompInfo :: new ( kind) ;
512
- ci. is_declaration = cursor. definition ( ) . unwrap ( ) . is_declaration ( ) ;
515
+ ci. is_forward_declaration = location. map_or ( true , |cur|
516
+ cur. is_definition ( ) && cur. kind ( ) == CXCursor_StructDecl ) ;
513
517
ci. is_anonymous = cursor. is_anonymous ( ) ;
514
518
ci. template_args = match ty. template_args ( ) {
515
519
// In forward declarations and not specializations,
@@ -861,8 +865,8 @@ impl CompInfo {
861
865
} )
862
866
}
863
867
864
- pub fn is_declaration ( & self ) -> bool {
865
- self . is_declaration
868
+ pub fn is_forward_declaration ( & self ) -> bool {
869
+ self . is_forward_declaration
866
870
}
867
871
}
868
872
0 commit comments