Skip to content

Commit c0605bc

Browse files
acozzettecopybara-github
authored andcommitted
Remove the Proxy trait
This trait does not seem to serve any useful purpose beyond what's already covered by the `ViewProxy` and `MutProxy` traits, so let's remove it to simplify things. PiperOrigin-RevId: 814844765
1 parent 076085b commit c0605bc

File tree

9 files changed

+8
-44
lines changed

9 files changed

+8
-44
lines changed

rust/cord.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
use crate::__internal::{Private, SealedInternal};
99
use crate::{
10-
AsView, IntoProxied, IntoView, ProtoBytes, ProtoStr, ProtoString, Proxied, Proxy, View,
11-
ViewProxy,
10+
AsView, IntoProxied, IntoView, ProtoBytes, ProtoStr, ProtoString, Proxied, View, ViewProxy,
1211
};
1312
use paste::paste;
1413
use std::cmp::PartialEq;
@@ -41,8 +40,6 @@ macro_rules! impl_cord_types {
4140
}
4241
}
4342

44-
impl<'msg> Proxy<'msg> for [< $t Cow>]<'msg> {}
45-
4643
impl<'msg> ViewProxy<'msg> for [< $t Cow>]<'msg> {}
4744

4845
impl<'msg> AsView for [< $t Cow>]<'msg> {

rust/map.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use crate::{
99
AsMut, AsView, IntoMut, IntoProxied, IntoView, Message, Mut, MutProxied, MutProxy, Proxied,
10-
Proxy, View, ViewProxy,
10+
View, ViewProxy,
1111
__internal::runtime::{InnerMap, InnerMapMut, RawMap, RawMapIter},
1212
__internal::{Private, SealedInternal},
1313
};
@@ -141,8 +141,6 @@ impl<K: Proxied, V: ProxiedInMapValue<K>> AsMut for Map<K, V> {
141141

142142
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> SealedInternal for MapView<'msg, K, V> {}
143143

144-
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> Proxy<'msg> for MapView<'msg, K, V> {}
145-
146144
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> AsView for MapView<'msg, K, V> {
147145
type Proxied = Map<K, V>;
148146

@@ -164,8 +162,6 @@ impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> ViewProxy<'msg> for MapView<'msg
164162

165163
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> SealedInternal for MapMut<'msg, K, V> {}
166164

167-
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> Proxy<'msg> for MapMut<'msg, K, V> {}
168-
169165
impl<'msg, K: Proxied, V: ProxiedInMapValue<K>> AsView for MapMut<'msg, K, V> {
170166
type Proxied = Map<K, V>;
171167

rust/primitive.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// license that can be found in the LICENSE file or at
66
// https://developers.google.com/open-source/licenses/bsd
77
use crate::__internal::SealedInternal;
8-
use crate::{AsView, IntoView, Proxied, Proxy, ViewProxy};
8+
use crate::{AsView, IntoView, Proxied, ViewProxy};
99

1010
macro_rules! impl_singular_primitives {
1111
($($t:ty),*) => {
@@ -16,9 +16,6 @@ macro_rules! impl_singular_primitives {
1616
type View<'msg> = $t;
1717
}
1818

19-
impl<'msg> Proxy<'msg> for $t {
20-
}
21-
2219
impl AsView for $t {
2320
type Proxied = $t;
2421

rust/proxied.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
//! indirection between the user and the internal memory representation.
4646
4747
use crate::__internal::{Private, SealedInternal};
48-
use std::fmt::Debug;
4948

5049
/// A type that can be accessed through a reference-like proxy.
5150
///
@@ -201,24 +200,14 @@ pub trait IntoMut<'msg>: SealedInternal + AsMut {
201200
'msg: 'shorter;
202201
}
203202

204-
/// Declares conversion operations common to all proxies (both views and mut
205-
/// proxies).
206-
///
207-
/// This trait is intentionally made non-object-safe to prevent a potential
208-
/// future incompatible change.
209-
pub trait Proxy<'msg>:
210-
SealedInternal + 'msg + IntoView<'msg> + Sync + Unpin + Sized + Debug
211-
{
212-
}
213-
214203
/// Declares conversion operations common to view proxies.
215-
pub trait ViewProxy<'msg>: SealedInternal + Proxy<'msg> + Send {}
204+
pub trait ViewProxy<'msg>: SealedInternal + Send + IntoView<'msg> {}
216205

217206
/// Declares operations common to all mut proxies.
218207
///
219208
/// This trait is intentionally made non-object-safe to prevent a potential
220209
/// future incompatible change.
221-
pub trait MutProxy<'msg>: SealedInternal + Proxy<'msg> + AsMut + IntoMut<'msg> {
210+
pub trait MutProxy<'msg>: SealedInternal + AsMut + IntoMut<'msg> + IntoView<'msg> {
222211
/// Gets an immutable view of this field. This is shorthand for `as_view`.
223212
///
224213
/// This provides a shorter lifetime than `into_view` but can also be called
@@ -306,8 +295,6 @@ mod tests {
306295
}
307296
}
308297

309-
impl<'msg> Proxy<'msg> for MyProxiedView<'msg> {}
310-
311298
impl<'msg> ViewProxy<'msg> for MyProxiedView<'msg> {}
312299

313300
impl<'msg> AsView for MyProxiedView<'msg> {
@@ -334,8 +321,6 @@ mod tests {
334321

335322
impl<'msg> SealedInternal for MyProxiedMut<'msg> {}
336323

337-
impl<'msg> Proxy<'msg> for MyProxiedMut<'msg> {}
338-
339324
impl<'msg> AsView for MyProxiedMut<'msg> {
340325
type Proxied = MyProxied;
341326

rust/repeated.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::marker::PhantomData;
1616

1717
use crate::{
1818
AsMut, AsView, IntoMut, IntoProxied, IntoView, Message, Mut, MutProxied, MutProxy, Proxied,
19-
Proxy, View, ViewProxy,
19+
View, ViewProxy,
2020
__internal::runtime::{InnerRepeated, InnerRepeatedMut, RawRepeatedField},
2121
__internal::{Private, SealedInternal},
2222
};
@@ -460,8 +460,6 @@ where
460460

461461
impl<'msg, T> SealedInternal for RepeatedView<'msg, T> where T: ProxiedInRepeated + 'msg {}
462462

463-
impl<'msg, T> Proxy<'msg> for RepeatedView<'msg, T> where T: ProxiedInRepeated + 'msg {}
464-
465463
impl<'msg, T> AsView for RepeatedView<'msg, T>
466464
where
467465
T: ProxiedInRepeated + 'msg,
@@ -491,8 +489,6 @@ impl<'msg, T> ViewProxy<'msg> for RepeatedView<'msg, T> where T: ProxiedInRepeat
491489

492490
impl<'msg, T> SealedInternal for RepeatedMut<'msg, T> where T: ProxiedInRepeated + 'msg {}
493491

494-
impl<'msg, T> Proxy<'msg> for RepeatedMut<'msg, T> where T: ProxiedInRepeated + 'msg {}
495-
496492
impl<'msg, T> AsView for RepeatedMut<'msg, T>
497493
where
498494
T: ProxiedInRepeated + 'msg,

rust/shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use crate::cord::{ProtoBytesCow, ProtoStringCow};
2525
pub use crate::map::{Map, MapIter, MapMut, MapView, ProxiedInMapValue};
2626
pub use crate::optional::Optional;
2727
pub use crate::proxied::{
28-
AsMut, AsView, IntoMut, IntoProxied, IntoView, Mut, MutProxied, MutProxy, Proxied, Proxy, View,
28+
AsMut, AsView, IntoMut, IntoProxied, IntoView, Mut, MutProxied, MutProxy, Proxied, View,
2929
ViewProxy,
3030
};
3131
pub use crate::r#enum::{Enum, UnknownEnumValue};

rust/string.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::__internal::runtime::InnerProtoString;
1313
use crate::__internal::{Private, SealedInternal};
1414
use crate::{
1515
utf8::Utf8Chunks, AsView, IntoProxied, IntoView, Mut, MutProxied, MutProxy, Optional, Proxied,
16-
Proxy, View, ViewProxy,
16+
View, ViewProxy,
1717
};
1818
use std::borrow::Cow;
1919
use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
@@ -131,8 +131,6 @@ impl IntoProxied<ProtoBytes> for Arc<[u8]> {
131131

132132
impl SealedInternal for &[u8] {}
133133

134-
impl<'msg> Proxy<'msg> for &'msg [u8] {}
135-
136134
impl AsView for &[u8] {
137135
type Proxied = ProtoBytes;
138136

@@ -534,8 +532,6 @@ impl AsView for ProtoString {
534532
}
535533
}
536534

537-
impl<'msg> Proxy<'msg> for &'msg ProtoStr {}
538-
539535
impl AsView for &ProtoStr {
540536
type Proxied = ProtoString;
541537

src/google/protobuf/compiler/rust/enum.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ void GenerateEnumDefinition(Context& ctx, const EnumDescriptor& desc,
277277
type View<'a> = $name$;
278278
}
279279
280-
impl $pb$::Proxy<'_> for $name$ {}
281280
impl $pb$::ViewProxy<'_> for $name$ {}
282281
283282
impl $pb$::AsView for $name$ {

src/google/protobuf/compiler/rust/message.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,6 @@ void GenerateRs(Context& ctx, const Descriptor& msg, const upb::DefPool& pool) {
608608
// - `$Msg$View` does not use thread-local data.
609609
unsafe impl Send for $Msg$View<'_> {}
610610
611-
impl<'msg> $pb$::Proxy<'msg> for $Msg$View<'msg> {}
612611
impl<'msg> $pb$::ViewProxy<'msg> for $Msg$View<'msg> {}
613612
614613
impl<'msg> $pb$::AsView for $Msg$View<'msg> {
@@ -683,7 +682,6 @@ void GenerateRs(Context& ctx, const Descriptor& msg, const upb::DefPool& pool) {
683682
// - `$Msg$Mut` does not perform any shared mutation.
684683
unsafe impl Sync for $Msg$Mut<'_> {}
685684
686-
impl<'msg> $pb$::Proxy<'msg> for $Msg$Mut<'msg> {}
687685
impl<'msg> $pb$::MutProxy<'msg> for $Msg$Mut<'msg> {}
688686
689687
impl<'msg> $pb$::AsView for $Msg$Mut<'msg> {

0 commit comments

Comments
 (0)