Skip to content

Commit 1eadd26

Browse files
committed
Extract function for writing cxx_impl_annotations
1 parent a5b8c38 commit 1eadd26

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

gen/src/write.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,17 @@ fn write_opaque_type_layout<'a>(out: &mut OutFile<'a>, ety: &'a ExternType) {
623623
writeln!(out, "}}");
624624
}
625625

626+
fn begin_function_definition(out: &mut OutFile) {
627+
if let Some(annotation) = &out.opt.cxx_impl_annotations {
628+
write!(out, "{} ", annotation);
629+
}
630+
}
631+
626632
fn write_cxx_function_shim<'a>(out: &mut OutFile<'a>, efn: &'a ExternFn) {
627633
out.next_section();
628634
out.set_namespace(&efn.name.namespace);
629635
out.begin_block(Block::ExternC);
630-
if let Some(annotation) = &out.opt.cxx_impl_annotations {
631-
write!(out, "{} ", annotation);
632-
}
636+
begin_function_definition(out);
633637
if efn.throws {
634638
out.builtin.ptr_len = true;
635639
write!(out, "::rust::repr::PtrLen ");

0 commit comments

Comments
 (0)