diff --git a/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc b/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc index 48aa4dbfca645..0185e662e3a38 100644 --- a/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc +++ b/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc @@ -122,7 +122,7 @@ void SingularScalar::InExternC(Context& ctx, {"getter_thunk", Thunk(ctx, field, "get")}, {"setter_thunk", Thunk(ctx, field, "set")}, {"clearer_thunk", Thunk(ctx, field, "clear")}, - {"hazzer_and_clearer", + {"thunks_for_with_presence_fields", [&] { if (field.has_presence()) { ctx.Emit( @@ -133,7 +133,7 @@ void SingularScalar::InExternC(Context& ctx, } }}}, R"rs( - $hazzer_and_clearer$ + $thunks_for_with_presence_fields$ fn $getter_thunk$(raw_msg: $pbi$::RawMessage) -> $Scalar$; fn $setter_thunk$(raw_msg: $pbi$::RawMessage, val: $Scalar$); )rs"); @@ -148,7 +148,7 @@ void SingularScalar::InThunkCc(Context& ctx, {"getter_thunk", Thunk(ctx, field, "get")}, {"setter_thunk", Thunk(ctx, field, "set")}, {"clearer_thunk", Thunk(ctx, field, "clear")}, - {"hazzer_and_clearer", + {"thunks_for_with_presence_fields", [&] { if (field.has_presence()) { ctx.Emit(R"cc( @@ -160,7 +160,7 @@ void SingularScalar::InThunkCc(Context& ctx, } }}}, R"cc( - $hazzer_and_clearer$; + $thunks_for_with_presence_fields$; $Scalar$ $getter_thunk$($QualifiedMsg$* msg) { return msg->$field$(); } void $setter_thunk$($QualifiedMsg$* msg, $Scalar$ val) { msg->set_$field$(val); diff --git a/src/google/protobuf/compiler/rust/accessors/singular_string.cc b/src/google/protobuf/compiler/rust/accessors/singular_string.cc index c70380c67c825..0927888dad8bb 100644 --- a/src/google/protobuf/compiler/rust/accessors/singular_string.cc +++ b/src/google/protobuf/compiler/rust/accessors/singular_string.cc @@ -118,13 +118,12 @@ void SingularString::InMsgImpl(Context& ctx, {"setter_thunk", setter_thunk}}, R"rs( pub fn $field$_mut(&mut self) -> $pb$::Mut<'_, $proxied_type$> { - static VTABLE: $pbi$::BytesMutVTable = unsafe { + static VTABLE: $pbi$::BytesMutVTable = $pbi$::BytesMutVTable::new( $pbi$::Private, $getter_thunk$, $setter_thunk$, - ) - }; + ); unsafe { <$pb$::Mut<$proxied_type$>>::from_inner( $pbi$::Private, @@ -158,19 +157,19 @@ void SingularString::InExternC(Context& ctx, {"getter_thunk", Thunk(ctx, field, "get")}, {"setter_thunk", Thunk(ctx, field, "set")}, {"clearer_thunk", Thunk(ctx, field, "clear")}, - {"hazzer", + {"thunks_for_with_presence_fields", [&] { if (field.has_presence()) { ctx.Emit(R"rs( fn $hazzer_thunk$(raw_msg: $pbi$::RawMessage) -> bool; + fn $clearer_thunk$(raw_msg: $pbi$::RawMessage); )rs"); } }}}, R"rs( - $hazzer$ + $thunks_for_with_presence_fields$ fn $getter_thunk$(raw_msg: $pbi$::RawMessage) -> $pbi$::PtrAndLen; fn $setter_thunk$(raw_msg: $pbi$::RawMessage, val: $pbi$::PtrAndLen); - fn $clearer_thunk$(raw_msg: $pbi$::RawMessage); )rs"); } @@ -182,7 +181,7 @@ void SingularString::InThunkCc(Context& ctx, {"getter_thunk", Thunk(ctx, field, "get")}, {"setter_thunk", Thunk(ctx, field, "set")}, {"clearer_thunk", Thunk(ctx, field, "clear")}, - {"hazzer", + {"thunks_for_with_presence_fields", [&] { if (field.has_presence()) { ctx.Emit(R"cc( @@ -194,7 +193,7 @@ void SingularString::InThunkCc(Context& ctx, } }}}, R"cc( - $hazzer$; + $thunks_for_with_presence_fields$; ::google::protobuf::rust_internal::PtrAndLen $getter_thunk$($QualifiedMsg$* msg) { absl::string_view val = msg->$field$(); return ::google::protobuf::rust_internal::PtrAndLen(val.data(), val.size()); diff --git a/src/google/protobuf/compiler/rust/generator.cc b/src/google/protobuf/compiler/rust/generator.cc index bc23a120216ea..c15f8743ff7a5 100644 --- a/src/google/protobuf/compiler/rust/generator.cc +++ b/src/google/protobuf/compiler/rust/generator.cc @@ -54,6 +54,7 @@ void EmitOpeningOfPackageModules(Context& ctx, absl::string_view pkg) { for (absl::string_view segment : absl::StrSplit(pkg, '.')) { ctx.Emit({{"segment", segment}}, R"rs( + #[allow(non_snake_case)] pub mod $segment$ { )rs"); } @@ -157,6 +158,7 @@ void DeclareSubmodulesForNonPrimarySrcs( {"mod_name", RustInternalModuleName(ctx, *non_primary_src)}}, R"rs( #[path="$file_path$"] + #[allow(non_snake_case)] pub mod $mod_name$; )rs"); } diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index 21151e3cc7790..408678367cc5b 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -175,7 +175,6 @@ void GetterForViewOrMut(Context& ctx, const FieldDescriptor& field, auto fieldType = field.type(); auto getter_thunk = Thunk(ctx, field, "get"); auto setter_thunk = Thunk(ctx, field, "set"); - auto clearer_thunk = Thunk(ctx, field, "clear"); // If we're dealing with a Mut, the getter must be supplied // self.inner.msg() whereas a View has to be supplied self.msg auto self = is_mut ? "self.inner.msg()" : "self.msg"; @@ -240,7 +239,6 @@ void GetterForViewOrMut(Context& ctx, const FieldDescriptor& field, ctx.Emit({{"field", fieldName}, {"getter_thunk", getter_thunk}, {"setter_thunk", setter_thunk}, - {"clearer_thunk", clearer_thunk}, {"self", self}, {"RsType", rsType}, {"as_ref", asRef},