@@ -509,6 +509,10 @@ impl Builder {
509
509
) ;
510
510
}
511
511
512
+ if !self . options . record_matches {
513
+ output_vector. push ( "--no-record-matches" . into ( ) ) ;
514
+ }
515
+
512
516
if !self . options . rustfmt_bindings {
513
517
output_vector. push ( "--no-rustfmt-bindings" . into ( ) ) ;
514
518
}
@@ -1137,6 +1141,12 @@ impl Builder {
1137
1141
self
1138
1142
}
1139
1143
1144
+ /// Set whether we should record matched items in our regex sets.
1145
+ pub fn record_matches ( mut self , doit : bool ) -> Self {
1146
+ self . options . record_matches = doit;
1147
+ self
1148
+ }
1149
+
1140
1150
/// Set the absolute path to the rustfmt configuration file, if None, the standard rustfmt
1141
1151
/// options are used.
1142
1152
pub fn rustfmt_configuration_file ( mut self , path : Option < PathBuf > ) -> Self {
@@ -1486,6 +1496,12 @@ struct BindgenOptions {
1486
1496
/// Features to enable, derived from `rust_target`
1487
1497
rust_features : RustFeatures ,
1488
1498
1499
+ /// Whether we should record which items in the regex sets ever matched.
1500
+ ///
1501
+ /// This may be a bit slower, but will enable reporting of unused whitelist
1502
+ /// items via the `error!` log.
1503
+ record_matches : bool ,
1504
+
1489
1505
/// Whether rustfmt should format the generated bindings.
1490
1506
rustfmt_bindings : bool ,
1491
1507
@@ -1511,20 +1527,26 @@ impl ::std::panic::UnwindSafe for BindgenOptions {}
1511
1527
1512
1528
impl BindgenOptions {
1513
1529
fn build ( & mut self ) {
1514
- self . whitelisted_vars . build ( ) ;
1515
- self . whitelisted_types . build ( ) ;
1516
- self . whitelisted_functions . build ( ) ;
1517
- self . blacklisted_types . build ( ) ;
1518
- self . blacklisted_functions . build ( ) ;
1519
- self . blacklisted_items . build ( ) ;
1520
- self . opaque_types . build ( ) ;
1521
- self . bitfield_enums . build ( ) ;
1522
- self . constified_enums . build ( ) ;
1523
- self . constified_enum_modules . build ( ) ;
1524
- self . rustified_enums . build ( ) ;
1525
- self . no_partialeq_types . build ( ) ;
1526
- self . no_copy_types . build ( ) ;
1527
- self . no_hash_types . build ( ) ;
1530
+ let mut regex_sets = [
1531
+ & mut self . whitelisted_vars ,
1532
+ & mut self . whitelisted_types ,
1533
+ & mut self . whitelisted_functions ,
1534
+ & mut self . blacklisted_types ,
1535
+ & mut self . blacklisted_functions ,
1536
+ & mut self . blacklisted_items ,
1537
+ & mut self . opaque_types ,
1538
+ & mut self . bitfield_enums ,
1539
+ & mut self . constified_enums ,
1540
+ & mut self . constified_enum_modules ,
1541
+ & mut self . rustified_enums ,
1542
+ & mut self . no_partialeq_types ,
1543
+ & mut self . no_copy_types ,
1544
+ & mut self . no_hash_types ,
1545
+ ] ;
1546
+ let record_matches = self . record_matches ;
1547
+ for regex_set in & mut regex_sets {
1548
+ regex_set. build ( record_matches) ;
1549
+ }
1528
1550
}
1529
1551
1530
1552
/// Update rust target version
@@ -1601,6 +1623,7 @@ impl Default for BindgenOptions {
1601
1623
enable_mangling : true ,
1602
1624
prepend_enum_name : true ,
1603
1625
time_phases : false ,
1626
+ record_matches : true ,
1604
1627
rustfmt_bindings : true ,
1605
1628
rustfmt_configuration_file : None ,
1606
1629
no_partialeq_types : Default :: default ( ) ,
0 commit comments