Fix message vtable::clear

Needed to pass in the message as a parameter to the clearer thunk!

Now the clear() augmentations in accessors_test.rs are working as expected.

PiperOrigin-RevId: 603394469
pull/15675/head
Hong Shin 10 months ago committed by Copybara-Service
parent 671b61b523
commit dc7001e517
  1. 9
      rust/test/shared/accessors_test.rs
  2. 3
      src/google/protobuf/compiler/rust/message.cc

@ -707,8 +707,7 @@ fn test_message_opt_set() {
assert_that!(msg.optional_nested_message_opt().is_set(), eq(true)); assert_that!(msg.optional_nested_message_opt().is_set(), eq(true));
msg.optional_nested_message_mut().clear(); msg.optional_nested_message_mut().clear();
// TODO: b/323222163 assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
// assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
} }
#[test] #[test]
@ -724,8 +723,7 @@ fn test_setting_submsg() {
assert_that!(msg.optional_nested_message_mut().is_set(), eq(true)); assert_that!(msg.optional_nested_message_mut().is_set(), eq(true));
msg.optional_nested_message_mut().clear(); msg.optional_nested_message_mut().clear();
// TODO: b/323222163 assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
// assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
} }
#[test] #[test]
@ -738,8 +736,7 @@ fn test_msg_or_default() {
assert_that!(msg.optional_nested_message_mut().is_set(), eq(true)); assert_that!(msg.optional_nested_message_mut().is_set(), eq(true));
msg.optional_nested_message_mut().clear(); msg.optional_nested_message_mut().clear();
// TODO: b/323222163 assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
//assert_that!(msg.optional_nested_message_mut().is_set(), eq(false));
} }
#[test] #[test]

@ -637,8 +637,7 @@ void GenerateRs(Context& ctx, const Descriptor& msg) {
-> Self::AbsentMutData<'_> { -> Self::AbsentMutData<'_> {
// SAFETY: The raw ptr msg_ref is valid // SAFETY: The raw ptr msg_ref is valid
unsafe { unsafe {
(present_mutator.optional_vtable().clearer); (present_mutator.optional_vtable().clearer)(present_mutator.msg_ref().msg());
(present_mutator.msg_ref().msg());
$pbi$::RawVTableOptionalMutatorData::new($pbi$::Private, $pbi$::RawVTableOptionalMutatorData::new($pbi$::Private,
present_mutator.msg_ref(), present_mutator.msg_ref(),

Loading…
Cancel
Save