From 69c75b498787c79e78397ba87a59dbffcd5ee586 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Wed, 6 Dec 2023 11:01:20 -0800 Subject: [PATCH] Cleanup mutable thunk usage in singular_message PiperOrigin-RevId: 588482350 --- .../protobuf/compiler/rust/accessors/singular_message.cc | 6 +++--- src/google/protobuf/compiler/rust/naming.cc | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/compiler/rust/accessors/singular_message.cc b/src/google/protobuf/compiler/rust/accessors/singular_message.cc index 5985c10085..210512a7eb 100644 --- a/src/google/protobuf/compiler/rust/accessors/singular_message.cc +++ b/src/google/protobuf/compiler/rust/accessors/singular_message.cc @@ -27,7 +27,7 @@ void SingularMessage::InMsgImpl(Context field) const { {"prefix", prefix}, {"field", field.desc().name()}, {"getter_thunk", Thunk(field, "get")}, - {"getter_mut_thunk", Thunk(field, "mutable")}, + {"getter_mut_thunk", Thunk(field, "get_mut")}, {"clearer_thunk", Thunk(field, "clear")}, { "view_body", @@ -91,7 +91,7 @@ void SingularMessage::InExternC(Context field) const { field.Emit( { {"getter_thunk", Thunk(field, "get")}, - {"getter_mut_thunk", Thunk(field, "mutable")}, + {"getter_mut_thunk", Thunk(field, "get_mut")}, {"clearer_thunk", Thunk(field, "clear")}, {"getter_mut", [&] { @@ -130,7 +130,7 @@ void SingularMessage::InThunkCc(Context field) const { field.Emit({{"QualifiedMsg", cpp::QualifiedClassName(field.desc().containing_type())}, {"getter_thunk", Thunk(field, "get")}, - {"getter_mut_thunk", Thunk(field, "mutable")}, + {"getter_mut_thunk", Thunk(field, "get_mut")}, {"clearer_thunk", Thunk(field, "clear")}, {"field", cpp::FieldName(&field.desc())}}, R"cc( diff --git a/src/google/protobuf/compiler/rust/naming.cc b/src/google/protobuf/compiler/rust/naming.cc index 198fbd16e4..6685493c04 100644 --- a/src/google/protobuf/compiler/rust/naming.cc +++ b/src/google/protobuf/compiler/rust/naming.cc @@ -84,7 +84,10 @@ std::string Thunk(Context field, absl::string_view op) { if (field.is_upb() && op == "get") { // upb getter is simply the field name (no "get" in the name). format = "_$1"; - } else if (field.is_upb() && (op == "case")) { + } else if (field.is_upb() && op == "get_mut") { + // same as above, with with `mutable` prefix + format = "_mutable_$1"; + } else if (field.is_upb() && op == "case") { // some upb functions are in the order x_op compared to has/set/clear which // are in the other order e.g. op_x. format = "_$1_$0";