Simplify gen_namespace_contents' extern block code
diff --git a/gen/src/write.rs b/gen/src/write.rs
index dcaec40..c008fcb 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -110,13 +110,11 @@
out.begin_block("extern \"C\"");
write_exception_glue(out, apis);
for api in apis {
- let (efn, write): (_, fn(_, _)) = match api {
- Api::CxxFunction(efn) => (efn, write_cxx_function_shim),
- Api::RustFunction(efn) => (efn, write_rust_function_decl),
- _ => continue,
- };
- out.next_section();
- write(out, efn);
+ match api {
+ Api::CxxFunction(efn) => write_cxx_function_shim(out, efn),
+ Api::RustFunction(efn) => write_rust_function_decl(out, efn),
+ _ => {}
+ }
}
out.end_block("extern \"C\"");
}
@@ -344,6 +342,7 @@
}
fn write_cxx_function_shim(out: &mut OutFile, efn: &ExternFn) {
+ out.next_section();
if let Some(annotation) = &out.opt.cxx_impl_annotations {
write!(out, "{} ", annotation);
}
@@ -532,7 +531,6 @@
var: &Ident,
f: &Signature,
) {
- out.next_section();
let r_trampoline = mangle::r_trampoline(efn, var, out.types);
let indirect_call = true;
write_rust_function_decl_impl(out, &r_trampoline, f, indirect_call);
@@ -554,6 +552,7 @@
sig: &Signature,
indirect_call: bool,
) {
+ out.next_section();
if sig.throws {
out.builtin.ptr_len = true;
write!(out, "::rust::repr::PtrLen ");