diff --git a/src/google/protobuf/compiler/rust/accessors/accessor_generator.h b/src/google/protobuf/compiler/rust/accessors/accessor_generator.h index 6aad7bba23..c440206f36 100644 --- a/src/google/protobuf/compiler/rust/accessors/accessor_generator.h +++ b/src/google/protobuf/compiler/rust/accessors/accessor_generator.h @@ -14,6 +14,7 @@ #include "absl/log/absl_check.h" #include "google/protobuf/compiler/rust/context.h" +#include "google/protobuf/compiler/rust/naming.h" #include "google/protobuf/descriptor.h" namespace google { @@ -38,6 +39,9 @@ class AccessorGenerator { const FieldDescriptor& field); void GenerateMsgImpl(Context& ctx, const FieldDescriptor& field) const { + ctx.Emit({{"comment", FieldInfoComment(ctx, field)}}, R"rs( + // $comment$ + )rs"); InMsgImpl(ctx, field); } void GenerateExternC(Context& ctx, const FieldDescriptor& field) const { diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index 6ead0f0bb3..a334f60ca6 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -363,11 +363,7 @@ void GenerateRs(Context& ctx, const Descriptor& msg) { {"accessor_fns", [&] { for (int i = 0; i < msg.field_count(); ++i) { - auto& field = *msg.field(i); - ctx.Emit({{"comment", FieldInfoComment(ctx, field)}}, R"rs( - // $comment$ - )rs"); - GenerateAccessorMsgImpl(ctx, field); + GenerateAccessorMsgImpl(ctx, *msg.field(i)); ctx.printer().PrintRaw("\n"); } }},