From 958dd59892938ebbac3aeda70bc0820325d40c88 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 14 Mar 2024 10:25:21 -0700 Subject: [PATCH] Remove the public _mut() accessors from string fields. PiperOrigin-RevId: 615824279 --- rust/test/cpp/debug_test.rs | 2 +- .../protobuf/compiler/rust/accessors/singular_string.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/test/cpp/debug_test.rs b/rust/test/cpp/debug_test.rs index d6feec36bc..eb9237ee72 100644 --- a/rust/test/cpp/debug_test.rs +++ b/rust/test/cpp/debug_test.rs @@ -5,7 +5,7 @@ use googletest::prelude::*; fn test_debug() { let mut msg = DebugMsg::new(); msg.set_id(1); - msg.secret_user_data_mut().set("password"); + msg.set_secret_user_data("password"); assert_that!(format!("{msg:?}"), contains_substring("id: 1")); assert_that!(format!("{msg:?}"), not(contains_substring("password"))); diff --git a/src/google/protobuf/compiler/rust/accessors/singular_string.cc b/src/google/protobuf/compiler/rust/accessors/singular_string.cc index b654edb604..15ab965882 100644 --- a/src/google/protobuf/compiler/rust/accessors/singular_string.cc +++ b/src/google/protobuf/compiler/rust/accessors/singular_string.cc @@ -135,7 +135,7 @@ void SingularString::InMsgImpl(Context& ctx, const FieldDescriptor& field, } if (field.has_presence()) { ctx.Emit(R"rs( - pub fn $raw_field_name$_mut(&mut self) -> $pb$::FieldEntry<'_, $proxied_type$> { + fn $raw_field_name$_mut(&mut self) -> $pb$::FieldEntry<'_, $proxied_type$> { let out = unsafe { let has = $hazzer_thunk$(self.raw_msg()); $pbi$::new_vtable_field_entry( @@ -150,7 +150,7 @@ void SingularString::InMsgImpl(Context& ctx, const FieldDescriptor& field, )rs"); } else { ctx.Emit(R"rs( - pub fn $raw_field_name$_mut(&mut self) -> $pb$::Mut<'_, $proxied_type$> { + fn $raw_field_name$_mut(&mut self) -> $pb$::Mut<'_, $proxied_type$> { unsafe { <$pb$::Mut<$proxied_type$>>::from_inner( $pbi$::Private,