@@ -19,7 +19,6 @@ use super::module::{Module, ModuleKind};
19
19
use super :: template:: { TemplateInstantiation , TemplateParameters } ;
20
20
use super :: traversal:: { self , Edge , ItemTraversal } ;
21
21
use super :: ty:: { FloatKind , Type , TypeKind } ;
22
- use crate :: callbacks:: ParseCallbacks ;
23
22
use crate :: clang:: { self , Cursor } ;
24
23
use crate :: parse:: ClangItemParser ;
25
24
use crate :: BindgenOptions ;
@@ -619,15 +618,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
619
618
)
620
619
}
621
620
622
- /// Get the user-provided callbacks by reference, if any.
623
- pub fn parse_callbacks ( & self ) -> Option < & dyn ParseCallbacks > {
624
- self . options ( ) . parse_callbacks . as_deref ( )
625
- }
626
-
627
621
/// Add another path to the set of included files.
628
622
pub fn include_file ( & mut self , filename : String ) {
629
- if let Some ( cbs ) = self . parse_callbacks ( ) {
630
- cbs . include_file ( & filename) ;
623
+ for cb in & self . options ( ) . parse_callbacks {
624
+ cb . include_file ( & filename) ;
631
625
}
632
626
self . deps . insert ( filename) ;
633
627
}
@@ -2240,19 +2234,24 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2240
2234
. or_insert_with ( || {
2241
2235
item. expect_type ( )
2242
2236
. name ( )
2243
- . and_then ( |name| match self . options . parse_callbacks {
2244
- Some ( ref cb ) => cb . blocklisted_type_implements_trait (
2245
- name ,
2246
- derive_trait ,
2247
- ) ,
2248
- // Sized integer types from <stdint.h> get mapped to Rust primitive
2249
- // types regardless of whether they are blocklisted, so ensure that
2250
- // standard traits are considered derivable for them too.
2251
- None => Some ( if self . is_stdint_type ( name ) {
2252
- CanDerive :: Yes
2237
+ . and_then ( |name| {
2238
+ if self . options . parse_callbacks . is_empty ( ) {
2239
+ // Sized integer types from <stdint.h> get mapped to Rust primitive
2240
+ // types regardless of whether they are blocklisted, so ensure that
2241
+ // standard traits are considered derivable for them too.
2242
+ if self . is_stdint_type ( name ) {
2243
+ Some ( CanDerive :: Yes )
2244
+ } else {
2245
+ Some ( CanDerive :: No )
2246
+ }
2253
2247
} else {
2254
- CanDerive :: No
2255
- } ) ,
2248
+ self . options . last_callback ( |cb| {
2249
+ cb. blocklisted_type_implements_trait (
2250
+ name,
2251
+ derive_trait,
2252
+ )
2253
+ } )
2254
+ }
2256
2255
} )
2257
2256
. unwrap_or ( CanDerive :: No )
2258
2257
} )
0 commit comments