Remove the public _mut() accessors from string fields.

PiperOrigin-RevId: 615824279
pull/16146/head
Protobuf Team Bot 9 months ago committed by Copybara-Service
parent 7e47fc3e39
commit 958dd59892
  1. 2
      rust/test/cpp/debug_test.rs
  2. 4
      src/google/protobuf/compiler/rust/accessors/singular_string.cc

@ -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")));

@ -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,

Loading…
Cancel
Save