Closed
Description
C and Rust comments are not the same. bindgen copies comments verbatim anyway, and this breaks things.
For example, here's an excerpt from a real-life header I was using with bindgen 0.19:
#include <stddef.h>
#include <stdint.h>
typedef uint32_t mbedtls_mpi_uint;
/**
* \brief MPI structure
*/
typedef struct
{
int s; /*!< integer sign */
size_t n; /*!< total # of limbs */
mbedtls_mpi_uint *p; /*!< pointer to limbs */
}
mbedtls_mpi;
bindgen 0.20 output for this type is:
/* automatically generated by rust-bindgen */
pub type mbedtls_mpi_uint = u32;
/**
* \brief MPI structure
*/
#[repr(C)]
#[derive(Debug, Copy)]
pub struct _bindgen_ty_2 {
/*!< integer sign */
pub s: ::std::os::raw::c_int,
/*!< total # of limbs */
pub n: usize,
/*!< pointer to limbs */
pub p: *mut mbedtls_mpi_uint,
}
#[test]
fn bindgen_test_layout__bindgen_ty_2() {
assert_eq!(::std::mem::size_of::<_bindgen_ty_2>() , 24usize);
assert_eq!(::std::mem::align_of::<_bindgen_ty_2>() , 8usize);
}
impl Clone for _bindgen_ty_2 {
fn clone(&self) -> Self { *self }
}
pub use self::_bindgen_ty_2 as mbedtls_mpi;
which rustc does not like:
error: expected outer doc comment
--> <anon>:10:5
|
10 | /*!< integer sign */
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items