@@ -418,6 +418,9 @@ impl Builder {
418
418
if self . options . enable_cxx_namespaces {
419
419
output_vector. push ( "--enable-cxx-namespaces" . into ( ) ) ;
420
420
}
421
+ if self . options . enable_function_attribute_detection {
422
+ output_vector. push ( "--enable-function-attribute-detection" . into ( ) ) ;
423
+ }
421
424
if self . options . disable_name_namespacing {
422
425
output_vector. push ( "--disable-name-namespacing" . into ( ) ) ;
423
426
}
@@ -1057,6 +1060,18 @@ impl Builder {
1057
1060
self
1058
1061
}
1059
1062
1063
+ /// Enable detecting must_use attributes on C functions.
1064
+ ///
1065
+ /// This is quite slow in some cases (see #1465), so it's disabled by
1066
+ /// default.
1067
+ ///
1068
+ /// Note that for this to do something meaningful for now at least, the rust
1069
+ /// target version has to have support for `#[must_use]`.
1070
+ pub fn enable_function_attribute_detection ( mut self ) -> Self {
1071
+ self . options . enable_function_attribute_detection = true ;
1072
+ self
1073
+ }
1074
+
1060
1075
/// Disable name auto-namespacing.
1061
1076
///
1062
1077
/// By default, bindgen mangles names like `foo::bar::Baz` to look like
@@ -1391,6 +1406,10 @@ struct BindgenOptions {
1391
1406
/// generated bindings.
1392
1407
enable_cxx_namespaces : bool ,
1393
1408
1409
+ /// True if we should try to find unexposed attributes in functions, in
1410
+ /// order to be able to generate #[must_use] attributes in Rust.
1411
+ enable_function_attribute_detection : bool ,
1412
+
1394
1413
/// True if we should avoid mangling names with namespaces.
1395
1414
disable_name_namespacing : bool ,
1396
1415
@@ -1618,6 +1637,7 @@ impl Default for BindgenOptions {
1618
1637
derive_partialeq : false ,
1619
1638
derive_eq : false ,
1620
1639
enable_cxx_namespaces : false ,
1640
+ enable_function_attribute_detection : false ,
1621
1641
disable_name_namespacing : false ,
1622
1642
use_core : false ,
1623
1643
ctypes_prefix : None ,
0 commit comments