Commit graph

72 commits

Author SHA1 Message Date
Protobuf Team Bot
796f71274c Set Rust edition 2024 for all protobuf and upb rust targets.
PiperOrigin-RevId: 936789455
2026-06-23 11:29:41 -07:00
Joshua Haberman
2b3058dcff Refactor: Split upb and cpp backends into submodules
This CL contains no functional change, it is a pure splitting of the existing files.

I elected to move the C++ kernel files to `cpp_kernel/` which already contained the C++ API for the C++ kernel.  Unfortunately this required removing the existing `third_party/protobuf/rust/cpp_kernel/BUILD` file, because, the Rust parts of the cpp kernel have circular dependencies with the shared code in `third_party/protobuf/rust`.

PiperOrigin-RevId: 886884124
2026-03-20 11:13:43 -07:00
Protobuf Team Bot
127b34f445 Automated Code Change
PiperOrigin-RevId: 877789010
2026-03-03 00:27:52 -08:00
Chris Kennelly
99753deb2e Suppress failure to consume parse/serialize return values.
PiperOrigin-RevId: 840725820
2025-12-05 08:01:34 -08:00
Protobuf Team Bot
793dbb91b6 Expose unstable message descriptor getter to Rust.
PiperOrigin-RevId: 822582353
2025-10-22 07:43:06 -07:00
Protobuf Team Bot
a9d0fd2406 Automated rollback of commit c381fa449c.
PiperOrigin-RevId: 820944027
2025-10-17 21:32:55 -07:00
Protobuf Team Bot
c381fa449c Expose unstable message descriptor getter to Rust.
PiperOrigin-RevId: 820862343
2025-10-17 16:12:08 -07:00
Hong Shin
f2adb4d47d internal change
PiperOrigin-RevId: 819316614
2025-10-14 11:30:30 -07:00
Adam Cozzette
3ff832936e Start testing against Rust edition 2024
This change also makes all the necessary fixes to get us compatible with
edition 2024.

I set things up so that we test edition 2024 with Bazel but keep Cargo on
edition 2021. This seems like a nice way to go since it allows us to get full
test coverage of both editions without us having to increment our minimum
supported Rust version.

PiperOrigin-RevId: 816241556
2025-10-07 09:21:51 -07:00
Protobuf Team Bot
158312dc8c Automated Code Change
PiperOrigin-RevId: 782733463
2025-07-13 20:59:16 -07:00
Protobuf Team Bot
28de0ebcdd Run buildifier
Adds missing loads for Java rules.
Remove unused loads.
Some other minor fixes.

PiperOrigin-RevId: 728701378
2025-02-19 09:27:02 -08:00
Sandy Zhang
ba6b54d6bc Upgrade abseil-cpp to 20250127 and use @com_google_absl -> @abseil-cpp and com_google_googletest -> @googletest canonical BCR names.
Users still using the old `WORKSPACE` system may need to do the same or use `repo_mapping` on repositories that still use the old names. See Abseil's release notes for details: https://github.com/abseil/abseil-cpp/releases/tag/20250127.

#test-continuous

PiperOrigin-RevId: 725247849
2025-02-10 09:43:53 -08:00
Protobuf Team Bot
84ed87e1a0 Upgrade to googletest 0.13 crate.
PiperOrigin-RevId: 705994414
2024-12-13 14:03:59 -08:00
Protobuf Team Bot
b025398f9c Move __runtime into __internal::runtime
Clarify the rustdoc on __internal

PiperOrigin-RevId: 703541883
2024-12-06 10:33:43 -08:00
Protobuf Team Bot
0325132bf4 Use the latest googletest version number in our generated Cargo.toml for release.
Crates.io does not allow publishing of Cargo.toml files which point to git.

PiperOrigin-RevId: 698801255
2024-11-21 09:04:17 -08:00
Protobuf Team Bot
6f8662c6f9 Remove a few things from Rust OSS tests.
PiperOrigin-RevId: 692256780
2024-11-01 12:40:02 -07:00
Protobuf Team Bot
a88dc0c5e6 Automated Code Change
PiperOrigin-RevId: 692150822
2024-11-01 06:17:28 -07:00
Protobuf Team Bot
0df6034ae9 Automated Code Change
PiperOrigin-RevId: 684357181
2024-10-10 09:21:32 -07:00
Protobuf Team Bot
6ae5db635e Enable rust/test/cpp/interop/... tests on GHA
PiperOrigin-RevId: 681051606
2024-10-01 09:33:20 -07:00
Protobuf Team Bot
5da098b8b0 Make SerializedData into a POD struct.
PiperOrigin-RevId: 676124916
2024-09-18 14:17:14 -07:00
Protobuf Team Bot
4671dce58a Fix visibility on "internal to any protobuf usage outside of this directory" for rust_library targets in OSS
PiperOrigin-RevId: 676060420
2024-09-18 11:29:04 -07:00
Protobuf Team Bot
4834eb75cb Move some :unittest_(cpp|upb)_rust_proto target to be colocated with the .proto file that defines them
This CL doesn't unbreak the bazel tests, but is yak shaving in prep for changes that will. This makes it more straightforward how the tests are broken by having bazel test rules name rust proto library targets that don't exist in bazel repo, instead of naming targets that do exist but are bogus.

Also correct unittest_edition target to match the order of words in the .proto file name (edition_unittest)

PiperOrigin-RevId: 674295376
2024-09-13 07:54:15 -07:00
Protobuf Team Bot
db3e837e02 Add an _unchecked_lifetime version of the Cpp interop wrap fns.
This is useful/necessary when the caller wants to tie the View to a lifetime other than a stack frame, including 'static.

The documentation is clarified that the preexisting one should be preferred in most situations, and only use the new one where tying the View lifetime to a stack frame isn't suitable.

PiperOrigin-RevId: 666396427
2024-08-22 10:15:25 -07:00
Protobuf Team Bot
b0db5bd029 Change CppInterop traits to operate on *const or *mut c_void instead of protobuf::__runtime::RawMessage
PiperOrigin-RevId: 665332958
2024-08-20 06:32:37 -07:00
Dmitri Gribenko
744c9ddfc5 Rename #[googletest::test] to #[gtest]
PiperOrigin-RevId: 661993029
2024-08-12 01:48:49 -07:00
Protobuf Team Bot
76c767fa1c Add traits for interop fns.
The owned and mut interop traits have the corresponding to/from behaviors on cpp but are defined as empty on upb, while the view interop is implemented for both.

PiperOrigin-RevId: 657617187
2024-07-30 09:18:48 -07:00
Protobuf Team Bot
461450834b Introduce a prelude and remove the inherent impls for serialize()
on msg, msgmut and msgview.

PiperOrigin-RevId: 656007820
2024-07-25 10:49:09 -07:00
Dmitri Gribenko
0a917b95f2 Use #[googletest::test] in Protobuf Rust
PiperOrigin-RevId: 654726974
2024-07-22 06:59:28 -07:00
Protobuf Team Bot
f810cc5b66 Enable MessageLite::DebugString to use Message::DebugString where possible.
This will mean that calling DebugString on a MessageLite* which is actually a full Message will get the debug info instead of the minimal output.

PiperOrigin-RevId: 649103508
2024-07-03 09:37:37 -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
Jakob Buchgraber
ec61d65a23 Fix debug_test to work with C++ lite
This change adds a cfg attribute 'cpp_lite' to the C++ kernel of Protobuf Rust. If C++ lite is selected on the command line, the cfg attribute 'cpp_lite' is set. The root cause of the test failure was that the Debug implementation for full C++ protos uses  text proto which is not available in C++ lite. The fix uses the 'cpp_lite' cfg attribute to select a different Debug implementation that doesn't rely on text proto

PiperOrigin-RevId: 640552701
2024-06-05 09:36:40 -07:00
Protobuf Team Bot
d0e79cf761 Actually make Serialize fallible on Rust-cpp.
PiperOrigin-RevId: 638998643
2024-05-31 05:10:40 -07:00
Protobuf Team Bot
fdc7f65849 Make serialization correctly be fallible in the Rust Protobuf API.
This doesn't _actually_ make the C++ Kernel path ever fail yet, but now that the API is a Result<SerializedData, SerializeError> it can be fixed as an implementation detail.

PiperOrigin-RevId: 638329136
2024-05-29 10:23:18 -07:00
Marcel Hlopko
69a26b217d Use the name of the rust_proto_library as the crate name
PiperOrigin-RevId: 634414403
2024-05-16 09:00:50 -07:00
Alyssa Haroldsen
3f493d9e52 Use the same set of exports as regular users in shared tests
The shared tests which access `protobuf_upb` or `protobuf_cpp`
have access to more items than the `protobuf` library itself.
This is because the former don't go through the same re-exporting based
on kernel.

I fix this by creating two test-only libraries that perform the same re-exporting
as the `protobuf` library, but with the kernel explicitly set, and changing the shared
tests to reference that instead of the inner runtime library.

This is needed to reliably test macros, where item paths are relative to the invocation,
not eagerly checked at the macro source.

PiperOrigin-RevId: 624328817
2024-04-12 16:51:49 -07:00
Protobuf Team Bot
2678e10c99 Create a upb rust directory.
The intent of this directory would be for a layer of Rust bindings that directly map to upb semantics; Rust Protobuf runtime would be layer on top of that Rust, instead of directly on the upb C api.

PiperOrigin-RevId: 624282429
2024-04-12 13:57:44 -07:00
Protobuf Team Bot
f421dc42b5 Change the Rust > C++ interop fns to be consuming-self, add a 'leak' to the name and a ManuallyDrop(self) on the owned message case.
PiperOrigin-RevId: 622159280
2024-04-05 06:17:14 -07:00
Protobuf Team Bot
7df9d5d970 Use $Msg$::parse() where sensible.
PiperOrigin-RevId: 618838455
2024-03-25 07:46:41 -07:00
Marcel Hlopko
71eed03fda Remove unnecessary tags
PiperOrigin-RevId: 616741588
2024-03-18 01:05:09 -07:00
Protobuf Team Bot
958dd59892 Remove the public _mut() accessors from string fields.
PiperOrigin-RevId: 615824279
2024-03-14 10:28:56 -07:00
Jakob Buchgraber
03687b798b #rust #protobuf Implement custom Debug for C++ kernel
This change implements a custom Debug for messages, views and muts in the C++ kernel. Debug defers to proto2::Utf8Format.

It implements this only for the C++ kernel. We will need to pull in additional dependencies beyond minitables to implement it for UPB as well. This will be done at a later point.

PiperOrigin-RevId: 613191236
2024-03-06 06:21:49 -08:00
Protobuf Team Bot
5a0135e65a Bring back 'flat' setters for singular scalars and strings.
The non-string field setters can bypass the vtables already, the string setters still go through the vtable path here because its more important to let them take an `impl SettableValue` to be able to set either a &str or a &ProtoStr already.

PiperOrigin-RevId: 609705233
2024-02-23 06:08:15 -08:00
Protobuf Team Bot
8d9fb756be Internal
PiperOrigin-RevId: 607329878
2024-02-15 07:49:05 -08:00
Marcel Hlopko
0f4cf16815 Depend directly on cc_proto_aspect in rust_cc_proto_library
We had to wait for cc_proto_aspect to be exposed in Bazel. Now it is, so we can
simplify our build rules

PiperOrigin-RevId: 600362773
2024-01-21 23:49:11 -08:00
Marcel Hlopko
c1d174f7d2 Stop codegenning module for .proto package
PiperOrigin-RevId: 599856754
2024-01-19 09:35:46 -08:00
Adam Cozzette
4ec9170bcd Fix layering check for usage of gtest
To satisfy the layering check, we need to depend on :gtest for the headers, in
addition to :gtest_main which provides the main() function.

There are a bunch of formatting changes as a side effect of this, but they
should be harmless.

PiperOrigin-RevId: 594318263
2023-12-28 14:41:48 -08:00
Hong Shin
52ee619733 Migrate all remaining instances of assert_eq! to googletest-rust sans strings
PiperOrigin-RevId: 592022421
2023-12-18 15:16:21 -08:00
Adrian Sadłocha
b19deb9275 Remove separate setters for singular scalars
PiperOrigin-RevId: 590609323
2023-12-13 08:39:01 -08:00
Protobuf Team Bot
e1bb7d65a8 Implement rust repeated scalars for cpp and upb
PiperOrigin-RevId: 574261929
2023-10-17 14:18:54 -07:00