@@ -623,13 +623,17 @@ fn write_opaque_type_layout<'a>(out: &mut OutFile<'a>, ety: &'a ExternType) {
623
623
writeln ! ( out, "}}" ) ;
624
624
}
625
625
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
+
626
632
fn write_cxx_function_shim < ' a > ( out : & mut OutFile < ' a > , efn : & ' a ExternFn ) {
627
633
out. next_section ( ) ;
628
634
out. set_namespace ( & efn. name . namespace ) ;
629
635
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) ;
633
637
if efn. throws {
634
638
out. builtin . ptr_len = true ;
635
639
write ! ( out, "::rust::repr::PtrLen " ) ;
@@ -946,6 +950,9 @@ fn write_rust_function_shim_impl(
946
950
// We've already defined this inside the struct.
947
951
return ;
948
952
}
953
+ if !out. header {
954
+ begin_function_definition ( out) ;
955
+ }
949
956
write_rust_function_shim_decl ( out, local_name, sig, indirect_call) ;
950
957
if out. header {
951
958
writeln ! ( out, ";" ) ;
@@ -1483,6 +1490,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
1483
1490
let instance = ident. to_symbol ( ) ;
1484
1491
1485
1492
writeln ! ( out, "template <>" ) ;
1493
+ begin_function_definition ( out) ;
1486
1494
writeln ! (
1487
1495
out,
1488
1496
"{} *Box<{}>::allocation::alloc() noexcept {{" ,
@@ -1492,6 +1500,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
1492
1500
writeln ! ( out, "}}" ) ;
1493
1501
1494
1502
writeln ! ( out, "template <>" ) ;
1503
+ begin_function_definition ( out) ;
1495
1504
writeln ! (
1496
1505
out,
1497
1506
"void Box<{}>::allocation::dealloc({} *ptr) noexcept {{" ,
@@ -1501,6 +1510,7 @@ fn write_rust_box_impl(out: &mut OutFile, ident: &Pair) {
1501
1510
writeln ! ( out, "}}" ) ;
1502
1511
1503
1512
writeln ! ( out, "template <>" ) ;
1513
+ begin_function_definition ( out) ;
1504
1514
writeln ! ( out, "void Box<{}>::drop() noexcept {{" , inner) ;
1505
1515
writeln ! ( out, " cxxbridge1$box${}$drop(this);" , instance) ;
1506
1516
writeln ! ( out, "}}" ) ;
@@ -1513,16 +1523,19 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
1513
1523
out. include . cstddef = true ;
1514
1524
1515
1525
writeln ! ( out, "template <>" ) ;
1526
+ begin_function_definition ( out) ;
1516
1527
writeln ! ( out, "Vec<{}>::Vec() noexcept {{" , inner) ;
1517
1528
writeln ! ( out, " cxxbridge1$rust_vec${}$new(this);" , instance) ;
1518
1529
writeln ! ( out, "}}" ) ;
1519
1530
1520
1531
writeln ! ( out, "template <>" ) ;
1532
+ begin_function_definition ( out) ;
1521
1533
writeln ! ( out, "void Vec<{}>::drop() noexcept {{" , inner) ;
1522
1534
writeln ! ( out, " return cxxbridge1$rust_vec${}$drop(this);" , instance) ;
1523
1535
writeln ! ( out, "}}" ) ;
1524
1536
1525
1537
writeln ! ( out, "template <>" ) ;
1538
+ begin_function_definition ( out) ;
1526
1539
writeln ! (
1527
1540
out,
1528
1541
"::std::size_t Vec<{}>::size() const noexcept {{" ,
@@ -1532,6 +1545,7 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
1532
1545
writeln ! ( out, "}}" ) ;
1533
1546
1534
1547
writeln ! ( out, "template <>" ) ;
1548
+ begin_function_definition ( out) ;
1535
1549
writeln ! (
1536
1550
out,
1537
1551
"::std::size_t Vec<{}>::capacity() const noexcept {{" ,
@@ -1545,11 +1559,13 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
1545
1559
writeln ! ( out, "}}" ) ;
1546
1560
1547
1561
writeln ! ( out, "template <>" ) ;
1562
+ begin_function_definition ( out) ;
1548
1563
writeln ! ( out, "const {} *Vec<{0}>::data() const noexcept {{" , inner) ;
1549
1564
writeln ! ( out, " return cxxbridge1$rust_vec${}$data(this);" , instance) ;
1550
1565
writeln ! ( out, "}}" ) ;
1551
1566
1552
1567
writeln ! ( out, "template <>" ) ;
1568
+ begin_function_definition ( out) ;
1553
1569
writeln ! (
1554
1570
out,
1555
1571
"void Vec<{}>::reserve_total(::std::size_t cap) noexcept {{" ,
@@ -1563,6 +1579,7 @@ fn write_rust_vec_impl(out: &mut OutFile, element: &RustName) {
1563
1579
writeln ! ( out, "}}" ) ;
1564
1580
1565
1581
writeln ! ( out, "template <>" ) ;
1582
+ begin_function_definition ( out) ;
1566
1583
writeln ! (
1567
1584
out,
1568
1585
"void Vec<{}>::set_len(::std::size_t len) noexcept {{" ,
0 commit comments