@@ -19,7 +19,6 @@ use super::module::{Module, ModuleKind};
1919use super :: template:: { TemplateInstantiation , TemplateParameters } ;
2020use super :: traversal:: { self , Edge , ItemTraversal } ;
2121use super :: ty:: { FloatKind , Type , TypeKind } ;
22- use crate :: callbacks:: ParseCallbacks ;
2322use crate :: clang:: { self , Cursor } ;
2423use crate :: parse:: ClangItemParser ;
2524use crate :: BindgenOptions ;
@@ -619,15 +618,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
619618 )
620619 }
621620
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-
627621 /// Add another path to the set of included files.
628622 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) ;
631625 }
632626 self . deps . insert ( filename) ;
633627 }
@@ -2240,19 +2234,24 @@ If you encounter an error missing from this list, please file an issue or a PR!"
22402234 . or_insert_with ( || {
22412235 item. expect_type ( )
22422236 . 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+ }
22532247 } 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+ }
22562255 } )
22572256 . unwrap_or ( CanDerive :: No )
22582257 } )
0 commit comments