From 20ccd9f67cb9294af7f988d784bb82b63cbcfff1 Mon Sep 17 00:00:00 2001 From: mtb0x1 Date: Tue, 18 Nov 2025 14:01:42 +0100 Subject: [PATCH] fix : make sure at least one header was provided --- bindgen-tests/tests/tests.rs | 6 ++++++ bindgen/lib.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/bindgen-tests/tests/tests.rs b/bindgen-tests/tests/tests.rs index 6e3c358d3e..ca9c552bb4 100644 --- a/bindgen-tests/tests/tests.rs +++ b/bindgen-tests/tests/tests.rs @@ -563,6 +563,12 @@ fn test_mixed_header_and_header_contents() { } } +#[test] +#[should_panic(expected = "No headers provided")] +fn test_no_header_provided() { + let _ = builder().generate(); +} + #[test] fn test_macro_fallback_non_system_dir() { let actual = builder() diff --git a/bindgen/lib.rs b/bindgen/lib.rs index 644d9a68d9..6bc817aca3 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -336,6 +336,11 @@ impl Builder { .map(String::into_boxed_str), ); + assert!( + !self.options.input_headers.is_empty() || + !self.options.input_header_contents.is_empty(), + "No headers provided" + ); for header in &self.options.input_headers { self.options .for_each_callback(|cb| cb.header_file(header.as_ref()));