From fe6963970c8c4ac582dbefe3b7ee4ebb251dd803 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Wed, 12 Jun 2024 05:26:09 -0700 Subject: [PATCH] Rename IntoProxied::into -> IntoProxied::into_proxied `into` is also used by `Into::into`, and these two often clash. PiperOrigin-RevId: 642584408 --- rust/proxied.rs | 2 +- rust/repeated.rs | 8 ++++---- .../compiler/rust/accessors/repeated_field.cc | 4 ++-- .../rust/accessors/singular_message.cc | 4 ++-- src/google/protobuf/compiler/rust/message.cc | 18 +++++++++--------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rust/proxied.rs b/rust/proxied.rs index 3d7124813e..d3fa32d687 100644 --- a/rust/proxied.rs +++ b/rust/proxied.rs @@ -217,7 +217,7 @@ where /// runtime. We expect it to change in backwards incompatible ways in the /// future. pub trait IntoProxied { - fn into(self, _private: Private) -> T; + fn into_proxied(self, _private: Private) -> T; } #[cfg(test)] diff --git a/rust/repeated.rs b/rust/repeated.rs index 280eeffc3e..436933d705 100644 --- a/rust/repeated.rs +++ b/rust/repeated.rs @@ -241,7 +241,7 @@ impl IntoProxied> for Repeated where T: ?Sized + ProxiedInRepeated, { - fn into(self, _private: Private) -> Repeated { + fn into_proxied(self, _private: Private) -> Repeated { self } } @@ -250,7 +250,7 @@ impl<'msg, T> IntoProxied> for RepeatedView<'msg, T> where T: 'msg + ?Sized + ProxiedInRepeated, { - fn into(self, _private: Private) -> Repeated { + fn into_proxied(self, _private: Private) -> Repeated { let mut repeated: Repeated = Repeated::new(); T::repeated_copy_from(self, repeated.as_mut()); repeated @@ -261,8 +261,8 @@ impl<'msg, T> IntoProxied> for RepeatedMut<'msg, T> where T: 'msg + ?Sized + ProxiedInRepeated, { - fn into(self, _private: Private) -> Repeated { - IntoProxied::into(self.as_view(), _private) + fn into_proxied(self, _private: Private) -> Repeated { + IntoProxied::into_proxied(self.as_view(), _private) } } diff --git a/src/google/protobuf/compiler/rust/accessors/repeated_field.cc b/src/google/protobuf/compiler/rust/accessors/repeated_field.cc index 8f5ee25d45..be31dc0b9b 100644 --- a/src/google/protobuf/compiler/rust/accessors/repeated_field.cc +++ b/src/google/protobuf/compiler/rust/accessors/repeated_field.cc @@ -119,7 +119,7 @@ void RepeatedField::InMsgImpl(Context& ctx, const FieldDescriptor& field, $field_number$ ) }; - let val = src.into($pbi$::Private); + let val = src.into_proxied($pbi$::Private); let inner = val.inner($pbi$::Private); self.arena().fuse(inner.arena()); @@ -137,7 +137,7 @@ void RepeatedField::InMsgImpl(Context& ctx, const FieldDescriptor& field, pub fn set_$raw_field_name$(&mut self, src: impl $pb$::IntoProxied<$pb$::Repeated<$RsType$>>) { // Prevent the memory from being deallocated. The setter // transfers ownership of the memory to the parent message. - let val = std::mem::ManuallyDrop::new(src.into($pbi$::Private)); + let val = std::mem::ManuallyDrop::new(src.into_proxied($pbi$::Private)); unsafe { $move_setter_thunk$(self.raw_msg(), val.inner($pbi$::Private).raw()); diff --git a/src/google/protobuf/compiler/rust/accessors/singular_message.cc b/src/google/protobuf/compiler/rust/accessors/singular_message.cc index 01f44fad36..83f58a85cb 100644 --- a/src/google/protobuf/compiler/rust/accessors/singular_message.cc +++ b/src/google/protobuf/compiler/rust/accessors/singular_message.cc @@ -116,7 +116,7 @@ void SingularMessage::InMsgImpl(Context& ctx, const FieldDescriptor& field, // The message and arena are dropped after the setter. The // memory remains allocated as we fuse the arena with the // parent message's arena. - let mut msg = val.into($pbi$::Private); + let mut msg = val.into_proxied($pbi$::Private); self.as_mutator_message_ref($pbi$::Private) .arena($pbi$::Private) .fuse(msg.as_mutator_message_ref($pbi$::Private).arena($pbi$::Private)); @@ -130,7 +130,7 @@ void SingularMessage::InMsgImpl(Context& ctx, const FieldDescriptor& field, ctx.Emit({}, R"rs( // Prevent the memory from being deallocated. The setter // transfers ownership of the memory to the parent message. - let mut msg = std::mem::ManuallyDrop::new(val.into($pbi$::Private)); + let mut msg = std::mem::ManuallyDrop::new(val.into_proxied($pbi$::Private)); unsafe { $set_allocated_thunk$(self.as_mutator_message_ref($pbi$::Private).msg(), msg.as_mutator_message_ref($pbi$::Private).msg()); diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index 4b138b931c..5fb4d01032 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -240,7 +240,7 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { case Kernel::kCpp: ctx.Emit({{"copy_from_thunk", ThunkName(ctx, msg, "copy_from")}}, R"rs( impl<'msg> $pb$::IntoProxied<$Msg$> for $Msg$View<'msg> { - fn into(self, _private: $pbi$::Private) -> $Msg$ { + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { let dst = $Msg$::new(); unsafe { $copy_from_thunk$(dst.inner.msg, self.msg) }; dst @@ -248,13 +248,13 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { } impl<'msg> $pb$::IntoProxied<$Msg$> for $Msg$Mut<'msg> { - fn into(self, _private: $pbi$::Private) -> $Msg$ { - $pb$::IntoProxied::into($pb$::ViewProxy::into_view(self), _private) + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { + $pb$::IntoProxied::into_proxied($pb$::ViewProxy::into_view(self), _private) } } impl $pb$::IntoProxied<$Msg$> for $Msg$ { - fn into(self, _private: $pbi$::Private) -> $Msg$ { + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { self } } @@ -264,7 +264,7 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { case Kernel::kUpb: ctx.Emit({{"minitable", UpbMinitableName(msg)}}, R"rs( impl<'msg> $pb$::IntoProxied<$Msg$> for $Msg$View<'msg> { - fn into(self, _private: $pbi$::Private) -> $Msg$ { + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { let dst = $Msg$::new(); unsafe { $pbr$::upb_Message_DeepCopy( dst.inner.msg, @@ -277,13 +277,13 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { } impl<'msg> $pb$::IntoProxied<$Msg$> for $Msg$Mut<'msg> { - fn into(self, _private: $pbi$::Private) -> $Msg$ { - $pb$::IntoProxied::into($pb$::ViewProxy::into_view(self), _private) + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { + $pb$::IntoProxied::into_proxied($pb$::ViewProxy::into_view(self), _private) } } impl $pb$::IntoProxied<$Msg$> for $Msg$ { - fn into(self, _private: $pbi$::Private) -> $Msg$ { + fn into_proxied(self, _private: $pbi$::Private) -> $Msg$ { self } } @@ -944,7 +944,7 @@ void GenerateRs(Context& ctx, const Descriptor& msg) { } pub fn to_owned(&self) -> $Msg$ { - $pb$::IntoProxied::into(*self, $pbi$::Private) + $pb$::IntoProxied::into_proxied(*self, $pbi$::Private) } $accessor_fns_for_views$