1- use bindgen:: callbacks:: TypeKind ;
2- use bindgen:: {
3- builder, Abi , AliasVariation , Builder , CodegenConfig , EnumVariation ,
1+ use crate :: {
2+ builder,
3+ callbacks:: {
4+ AttributeInfo , DeriveInfo , ItemInfo , ParseCallbacks , TypeKind ,
5+ } ,
6+ features:: RUST_TARGET_STRINGS ,
7+ Abi , AliasVariation , Builder , CodegenConfig , EnumVariation ,
48 FieldVisibilityKind , Formatter , MacroTypeVariation , NonCopyUnionStyle ,
5- RegexSet , RustTarget , DEFAULT_ANON_FIELDS_PREFIX , RUST_TARGET_STRINGS ,
9+ RegexSet , RustTarget , DEFAULT_ANON_FIELDS_PREFIX ,
10+ } ;
11+ use clap:: {
12+ error:: { Error , ErrorKind } ,
13+ CommandFactory , Parser ,
614} ;
7- use clap:: error:: { Error , ErrorKind } ;
8- use clap:: { CommandFactory , Parser } ;
915use proc_macro2:: TokenStream ;
1016use std:: fs:: File ;
1117use std:: io;
@@ -491,6 +497,7 @@ struct BindgenCommand {
491497 #[ arg( long, value_name = "VISIBILITY" ) ]
492498 default_visibility : Option < FieldVisibilityKind > ,
493499 /// Whether to emit diagnostics or not.
500+ #[ cfg( feature = "experimental" ) ]
494501 #[ arg( long, requires = "experimental" ) ]
495502 emit_diagnostics : bool ,
496503 /// Generates completions for the specified SHELL, sends them to `stdout` and exits.
@@ -633,6 +640,7 @@ where
633640 wrap_static_fns_path,
634641 wrap_static_fns_suffix,
635642 default_visibility,
643+ #[ cfg( feature = "experimental" ) ]
636644 emit_diagnostics,
637645 generate_shell_completions,
638646 experimental: _,
@@ -657,7 +665,7 @@ where
657665 option_env!( "CARGO_PKG_VERSION" ) . unwrap_or( "unknown" )
658666 ) ;
659667 if verbose {
660- println ! ( "Clang: {}" , bindgen :: clang_version( ) . full) ;
668+ println ! ( "Clang: {}" , crate :: clang_version( ) . full) ;
661669 }
662670 std:: process:: exit ( 0 ) ;
663671 }
@@ -1046,10 +1054,10 @@ where
10461054 prefix : String ,
10471055 }
10481056
1049- impl bindgen :: callbacks :: ParseCallbacks for PrefixLinkNameCallback {
1057+ impl ParseCallbacks for PrefixLinkNameCallback {
10501058 fn generated_link_name_override (
10511059 & self ,
1052- item_info : bindgen :: callbacks :: ItemInfo < ' _ > ,
1060+ item_info : ItemInfo < ' _ > ,
10531061 ) -> Option < String > {
10541062 let mut prefix = self . prefix . clone ( ) ;
10551063 prefix. push_str ( item_info. name ) ;
@@ -1114,10 +1122,10 @@ where
11141122 struct CustomDeriveCallback {
11151123 derives : Vec < String > ,
11161124 kind : Option < TypeKind > ,
1117- regex_set : bindgen :: RegexSet ,
1125+ regex_set : RegexSet ,
11181126 }
11191127
1120- impl bindgen :: callbacks :: ParseCallbacks for CustomDeriveCallback {
1128+ impl ParseCallbacks for CustomDeriveCallback {
11211129 fn cli_args ( & self ) -> Vec < String > {
11221130 let mut args = vec ! [ ] ;
11231131
@@ -1140,10 +1148,7 @@ where
11401148 args
11411149 }
11421150
1143- fn add_derives (
1144- & self ,
1145- info : & bindgen:: callbacks:: DeriveInfo < ' _ > ,
1146- ) -> Vec < String > {
1151+ fn add_derives ( & self , info : & DeriveInfo < ' _ > ) -> Vec < String > {
11471152 if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true ) &&
11481153 self . regex_set . matches ( info. name )
11491154 {
@@ -1153,7 +1158,7 @@ where
11531158 }
11541159 }
11551160
1156- for ( custom_derives, kind, name ) in [
1161+ for ( custom_derives, kind, _name ) in [
11571162 ( with_derive_custom, None , "--with-derive-custom" ) ,
11581163 (
11591164 with_derive_custom_struct,
@@ -1171,11 +1176,17 @@ where
11711176 "--with-derive-custom-union" ,
11721177 ) ,
11731178 ] {
1174- let name = emit_diagnostics. then_some ( name) ;
1179+ #[ cfg( feature = "experimental" ) ]
1180+ let name = emit_diagnostics. then_some ( _name) ;
1181+
11751182 for ( derives, regex) in custom_derives {
11761183 let mut regex_set = RegexSet :: new ( ) ;
11771184 regex_set. insert ( regex) ;
1185+
1186+ #[ cfg( feature = "experimental" ) ]
11781187 regex_set. build_with_diagnostics ( false , name) ;
1188+ #[ cfg( not( feature = "experimental" ) ) ]
1189+ regex_set. build ( false ) ;
11791190
11801191 builder = builder. parse_callbacks ( Box :: new ( CustomDeriveCallback {
11811192 derives,
@@ -1189,10 +1200,10 @@ where
11891200 struct CustomAttributeCallback {
11901201 attributes : Vec < String > ,
11911202 kind : Option < TypeKind > ,
1192- regex_set : bindgen :: RegexSet ,
1203+ regex_set : RegexSet ,
11931204 }
11941205
1195- impl bindgen :: callbacks :: ParseCallbacks for CustomAttributeCallback {
1206+ impl ParseCallbacks for CustomAttributeCallback {
11961207 fn cli_args ( & self ) -> Vec < String > {
11971208 let mut args = vec ! [ ] ;
11981209
@@ -1215,10 +1226,7 @@ where
12151226 args
12161227 }
12171228
1218- fn add_attributes (
1219- & self ,
1220- info : & bindgen:: callbacks:: AttributeInfo < ' _ > ,
1221- ) -> Vec < String > {
1229+ fn add_attributes ( & self , info : & AttributeInfo < ' _ > ) -> Vec < String > {
12221230 if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true ) &&
12231231 self . regex_set . matches ( info. name )
12241232 {
@@ -1228,7 +1236,7 @@ where
12281236 }
12291237 }
12301238
1231- for ( custom_attributes, kind, name ) in [
1239+ for ( custom_attributes, kind, _name ) in [
12321240 ( with_attribute_custom, None , "--with-attribute-custom" ) ,
12331241 (
12341242 with_attribute_custom_struct,
@@ -1246,11 +1254,17 @@ where
12461254 "--with-attribute-custom-union" ,
12471255 ) ,
12481256 ] {
1249- let name = emit_diagnostics. then_some ( name) ;
1257+ #[ cfg( feature = "experimental" ) ]
1258+ let name = emit_diagnostics. then_some ( _name) ;
1259+
12501260 for ( attributes, regex) in custom_attributes {
12511261 let mut regex_set = RegexSet :: new ( ) ;
12521262 regex_set. insert ( regex) ;
1263+
1264+ #[ cfg( feature = "experimental" ) ]
12531265 regex_set. build_with_diagnostics ( false , name) ;
1266+ #[ cfg( not( feature = "experimental" ) ) ]
1267+ regex_set. build ( false ) ;
12541268
12551269 builder =
12561270 builder. parse_callbacks ( Box :: new ( CustomAttributeCallback {
@@ -1277,6 +1291,7 @@ where
12771291 builder = builder. default_visibility ( visibility) ;
12781292 }
12791293
1294+ #[ cfg( feature = "experimental" ) ]
12801295 if emit_diagnostics {
12811296 builder = builder. emit_diagnostics ( ) ;
12821297 }
0 commit comments