Change MsgMut's _mut() accessors to use (&mut self) instead of (&self)

If this took a &self there were holes in thread and memory safety, because it's allowed to get multiple &MsgMuts (but only &mut MsgMuts).

PiperOrigin-RevId: 596991263
pull/15355/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 0b5cd4e9ef
commit e5b547bcb8
  1. 2
      rust/test/shared/simple_nested_test.rs
  2. 2
      src/google/protobuf/compiler/rust/message.cc

@ -73,7 +73,7 @@ fn test_nested_muts() {
}
let mut outer_msg = Outer::new();
let inner_msg: InnerMut<'_> = outer_msg.inner_mut();
let mut inner_msg: InnerMut<'_> = outer_msg.inner_mut();
assert_that!(
inner_msg,
matches_pattern!(InnerMut{

@ -304,7 +304,7 @@ void GetterForViewOrMut(Context& ctx, const FieldDescriptor& field,
// TODO: check mutational pathway genn'd correctly
if (is_mut) {
ctx.Emit({}, R"rs(
pub fn r#$field$_mut(&self) -> $pb$::Mut<'_, $RsType$> {
pub fn r#$field$_mut(&mut self) -> $pb$::Mut<'_, $RsType$> {
static VTABLE: $pbi$::$vtable$$optional_type_args$ =
$pbi$::$vtable$::new(
$pbi$::Private,

Loading…
Cancel
Save