Open
Description
Input C/C++ Header
template <class a> class Range { a b, c; };
typedef Range<const char *> StringPiece;
typedef Range<char> MutableStringPiece;
Range<char const *> d() {}
Bindgen Invocation
$ bindgen input.h --whitelist-type '(Mutable)?StringPiece' --generate=types --opaque-type '(Mutable)?StringPiece' --no-layout-tests -- -x c++ -std=gnu++14
Actual Results
/* automatically generated by rust-bindgen */
pub type StringPiece = [u64; 2usize];
pub type MutableStringPiece = u8;
Expected Results
pub type StringPiece = [u64; 2usize];
pub type MutableStringPiece = [u64; 2usize];
StringPiece
has a Rust type which correctly reflects its representation: [u64; 2size]
, which allows the Rust version of the type to be moved around etc. The MutableStringPiece
is misrepresented by u8
, which results in runtime errors because only the first byte is moved.
It looks like the d()
function is what makes the difference; if I remove this then both StringPiece
and MutableStringPiece
get the same incorrect u8
representation.
This seems to be a regression introduced about 0.31, but I haven't checked specifically.
cc @kulshrax