Fix missing panic template when using Vec
#277
diff --git a/gen/src/write.rs b/gen/src/write.rs
index b31a239..4bc633f 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -141,6 +141,7 @@
}
fn write_include_cxxbridge(out: &mut OutFile, apis: &[Api], types: &Types) {
+ let mut needs_panic = false;
let mut needs_rust_string = false;
let mut needs_rust_str = false;
let mut needs_rust_slice = false;
@@ -160,6 +161,7 @@
out.include.array = true;
out.include.new = true;
out.include.type_traits = true;
+ needs_panic = true;
needs_rust_vec = true;
needs_unsafe_bitcopy = true;
}
@@ -233,7 +235,8 @@
out.begin_block("namespace rust");
out.begin_block("inline namespace cxxbridge04");
- if needs_rust_string
+ if needs_panic
+ || needs_rust_string
|| needs_rust_str
|| needs_rust_slice
|| needs_rust_box
@@ -249,6 +252,8 @@
writeln!(out, "// #include \"rust/cxx.h\"");
}
+ include::write(out, needs_panic, "CXXBRIDGE04_PANIC");
+
if needs_rust_string {
out.next_section();
writeln!(out, "struct unsafe_bitcopy_t;");
diff --git a/include/cxx.h b/include/cxx.h
index f050248..23e7959 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -283,8 +283,11 @@
////////////////////////////////////////////////////////////////////////////////
/// end public API, begin implementation details
+#ifndef CXXBRIDGE04_PANIC
+#define CXXBRIDGE04_PANIC
template <typename Exception>
void panic [[noreturn]] (const char *msg);
+#endif // CXXBRIDGE04_PANIC
template <typename Ret, typename... Args, bool Throws>
Ret Fn<Ret(Args...), Throws>::operator()(Args... args) const noexcept(!Throws) {