Commit graph

5 commits

Author SHA1 Message Date
Protobuf Team Bot
7fbb3d2cc7 Make conversion functions for into c++ string types from PtrAndLen.
The invariant is that PtrAndLen may hold ptr+len values which are legal for _either_ C++ string_view or Rust slices: constructing one from either Rust or C++ permits the laxest constraints, and care must be taken when converting a PtrAndLen into either type.

For "into Rust slice" case to handle is that len=0 ptr must be non-null, so len=0 ptr=null gets turned into an arbitrary non-null pointer as provided by std::ptr::NonNull::dangling() (any preexisting non-null ptr is kept in that direction).

For the "into C++ slice" the risk is more obscure that a Rust non-null pointer could potentially be an illegal pointer (such that ptr+0 is not a legal operation in C++), so when going into C++ we map any len=0 cases into ptr=null to avoid this as a possible risk.

PiperOrigin-RevId: 704776210
2024-12-10 11:15:00 -08:00
Mike Kruskal
5695a882bd Move -Werror to our test/dev bazelrc files.
Putting it into BUILD files unintentionally forces it on all our downstream users.  Instead, we just want to enable this during testing and let them choose for themselves in their builds.

Note, that this expands the scope of -Werror to our entire repo for CI, so a bunch of fixes and opt-outs had to be applied to get this change passing.

Closed #14714

PiperOrigin-RevId: 666903224
2024-08-23 13:26:32 -07:00
Jakob Buchgraber
64912c50cb Use a std::string as the backing string & bytes type in the C++ kernel. This will allow us to move a ProtoString/Bytes to a message accessor without copying. This change only touches the C++ kernel, as the UPB kernel already uses the native arena-allocated UPB string type for ProtoString/Bytes.
PiperOrigin-RevId: 649004435
2024-07-03 02:59:06 -07:00
Protobuf Team Bot
c07de7c9df Change to proto2_rust C prefix and proto2::rust C++ namespace
PiperOrigin-RevId: 648791688
2024-07-02 11:44:17 -07:00
Protobuf Team Bot
419760f873 Split up cpp_api.h/.cc into smaller units.
PiperOrigin-RevId: 647663342
2024-06-28 06:54:35 -07:00