File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -33,19 +33,6 @@ mod log_stubs;
33
33
#[ macro_use]
34
34
mod extra_assertions;
35
35
36
- /// Print all the warning messages raised while generating the bindings in a build script.
37
- ///
38
- /// If you are using `bindgen` outside of a build script you should use [`Bindings::take_warnings`]
39
- /// directly instead.
40
- #[ macro_export]
41
- macro_rules! print_warnings {
42
- ( $bindings: expr) => {
43
- for message in $bindings. take_warnings( ) {
44
- println!( "cargo:warning={}" , message) ;
45
- }
46
- } ;
47
- }
48
-
49
36
// A macro to declare an internal module for which we *must* provide
50
37
// documentation for. If we are building with the "testing_only_docs" feature,
51
38
// then the module is declared public, and our `#![deny(missing_docs)]` pragma
@@ -2599,10 +2586,21 @@ impl Bindings {
2599
2586
}
2600
2587
}
2601
2588
2602
- /// Take all the warning messages.
2589
+ /// Emit all the warning messages raised while generating the bindings in a build script.
2590
+ ///
2591
+ /// If you are using `bindgen` outside of a build script you should use [`Bindings::warnings`]
2592
+ /// and handle the messages accordingly instead.
2593
+ #[ inline]
2594
+ pub fn emit_warnings ( & self ) {
2595
+ for message in & self . warnings {
2596
+ println ! ( "cargo:warning={}" , message) ;
2597
+ }
2598
+ }
2599
+
2600
+ /// Return all the warning messages raised while generating the bindings.
2603
2601
#[ inline]
2604
- pub fn take_warnings ( & mut self ) -> impl Iterator < Item = String > + ' _ {
2605
- self . warnings . drain ( .. )
2602
+ pub fn warnings ( & self ) -> & [ String ] {
2603
+ & self . warnings
2606
2604
}
2607
2605
}
2608
2606
Original file line number Diff line number Diff line change @@ -678,11 +678,11 @@ fn allowlist_warnings() {
678
678
"/tests/headers/allowlist_warnings.h"
679
679
) ;
680
680
681
- let mut bindings = builder ( )
681
+ let bindings = builder ( )
682
682
. header ( header)
683
683
. allowlist_function ( "doesnt_match_anything" )
684
684
. generate ( )
685
685
. expect ( "unable to generate bindings" ) ;
686
686
687
- assert_eq ! ( 1 , bindings. take_warnings ( ) . count ( ) ) ;
687
+ assert_eq ! ( 1 , bindings. warnings ( ) . len ( ) ) ;
688
688
}
You can’t perform that action at this time.
0 commit comments