ptr is a non-mutable binding containing a mutable pointer. A reference to it is of Rust type &*mut Foo. Currently cpp_build converts this to const Foo* & which is equivalent to Rust type &mut *const Foo. With this change, it converts it to Foo* const& which is equivalent to &*mut Foo.
Similar problems arise attempting to use "const char*" as the C++-side type for *const c_char, resulting in duplicate const.
To see why the old behavior was incorrect, consider this case:
ptr
is a non-mutable binding containing a mutable pointer. A reference to it is of Rust type&*mut Foo
. Currentlycpp_build
converts this toconst Foo* &
which is equivalent to Rust type&mut *const Foo
. With this change, it converts it toFoo* const&
which is equivalent to&*mut Foo
.Similar problems arise attempting to use
"const char*"
as the C++-side type for*const c_char
, resulting in duplicateconst
.