@@ -18,7 +18,7 @@ use std::{mem, ptr, slice};
18
18
/// function.
19
19
pub struct Attribute {
20
20
name : & ' static [ u8 ] ,
21
- kind : CXCursorKind ,
21
+ kind : Option < CXCursorKind > ,
22
22
token_kind : CXTokenKind ,
23
23
}
24
24
@@ -27,14 +27,14 @@ impl Attribute {
27
27
pub const MUST_USE : Self = Self {
28
28
name : b"warn_unused_result" ,
29
29
// FIXME(emilio): clang-sys doesn't expose `CXCursor_WarnUnusedResultAttr` (from clang 9).
30
- kind : 440 ,
30
+ kind : Some ( 440 ) ,
31
31
token_kind : CXToken_Identifier ,
32
32
} ;
33
33
34
34
/// A `_Noreturn` attribute.
35
35
pub const NO_RETURN : Self = Self {
36
36
name : b"_Noreturn" ,
37
- kind : CXCursor_UnexposedAttr ,
37
+ kind : None ,
38
38
token_kind : CXToken_Keyword ,
39
39
} ;
40
40
}
@@ -678,11 +678,13 @@ impl Cursor {
678
678
for ( idx, attr) in attrs. iter ( ) . enumerate ( ) {
679
679
let found_attr = & mut found_attrs[ idx] ;
680
680
if !* found_attr {
681
- if kind == attr. kind &&
682
- cur. tokens ( ) . iter ( ) . any ( |t| {
683
- t. kind == attr. token_kind &&
684
- t. spelling ( ) == attr. name
685
- } )
681
+ // `attr.name` and` attr.token_kind` are checked against unexposed attributes only.
682
+ if attr. kind . map_or ( false , |k| k == kind) ||
683
+ ( kind == CXCursor_UnexposedAttr &&
684
+ cur. tokens ( ) . iter ( ) . any ( |t| {
685
+ t. kind == attr. token_kind &&
686
+ t. spelling ( ) == attr. name
687
+ } ) )
686
688
{
687
689
* found_attr = true ;
688
690
found_count += 1 ;
0 commit comments