diff --git a/rust/cpp.rs b/rust/cpp.rs index 63f79f3f59..7d4cf56d63 100644 --- a/rust/cpp.rs +++ b/rust/cpp.rs @@ -691,8 +691,8 @@ impl UntypedMapIterator { from_ffi_value: impl FnOnce(FfiValue) -> View<'a, V>, ) -> Option<(View<'a, K>, View<'a, V>)> where - K: Proxied + ?Sized + 'a, - V: ProxiedInMapValue + ?Sized + 'a, + K: Proxied + 'a, + V: ProxiedInMapValue + 'a, { if self.at_end() { return None; diff --git a/rust/map.rs b/rust/map.rs index 170f50c97d..0e7953f872 100644 --- a/rust/map.rs +++ b/rust/map.rs @@ -59,19 +59,19 @@ impl<'msg, K: ?Sized, V: ?Sized> std::fmt::Debug for MapMut<'msg, K, V> { } } -pub struct Map> { +pub struct Map> { inner: InnerMap, _phantom: PhantomData<(PhantomData, PhantomData)>, } // SAFETY: `Map` is Sync because it does not implement interior mutability. -unsafe impl> Sync for Map {} +unsafe impl> Sync for Map {} // SAFETY: `Map` is Send because it's not bound to a specific thread e.g. // it does not use thread-local data or similar. -unsafe impl> Send for Map {} +unsafe impl> Send for Map {} -impl> Drop for Map { +impl> Drop for Map { fn drop(&mut self) { // SAFETY: // - `drop` is only called once. @@ -82,7 +82,7 @@ impl> Drop for Map { pub trait ProxiedInMapValue: Proxied where - K: Proxied + ?Sized, + K: Proxied, { fn map_new(_private: Private) -> Map; @@ -104,17 +104,15 @@ where fn map_iter_next<'a>(iter: &mut MapIter<'a, K, Self>) -> Option<(View<'a, K>, View<'a, Self>)>; } -impl + ?Sized> Proxied for Map { +impl> Proxied for Map { type View<'msg> = MapView<'msg, K, V> where K: 'msg, V: 'msg; } -impl + ?Sized> MutProxied for Map { +impl> MutProxied for Map { type Mut<'msg> = MapMut<'msg, K, V> where K: 'msg, V: 'msg; } -impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> Proxy<'msg> - for MapView<'msg, K, V> -{ +impl<'msg, K: Proxied, V: ProxiedInMapValue> Proxy<'msg> for MapView<'msg, K, V> { type Proxied = Map; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -129,14 +127,9 @@ impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> Proxy<'msg> } } -impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> ViewProxy<'msg> - for MapView<'msg, K, V> -{ -} +impl<'msg, K: Proxied, V: ProxiedInMapValue> ViewProxy<'msg> for MapView<'msg, K, V> {} -impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> Proxy<'msg> - for MapMut<'msg, K, V> -{ +impl<'msg, K: Proxied, V: ProxiedInMapValue> Proxy<'msg> for MapMut<'msg, K, V> { type Proxied = Map; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -151,9 +144,7 @@ impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> Proxy<'msg> } } -impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> MutProxy<'msg> - for MapMut<'msg, K, V> -{ +impl<'msg, K: Proxied, V: ProxiedInMapValue> MutProxy<'msg> for MapMut<'msg, K, V> { fn as_mut(&mut self) -> Mut<'_, Self::Proxied> { MapMut { inner: self.inner, _phantom: PhantomData } } @@ -168,8 +159,8 @@ impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue + ?Sized> MutProxy<'msg> impl Map where - K: Proxied + ?Sized, - V: ProxiedInMapValue + ?Sized, + K: Proxied, + V: ProxiedInMapValue, { pub fn new() -> Self { V::map_new(Private) @@ -195,8 +186,8 @@ where impl Default for Map where - K: Proxied + ?Sized, - V: ProxiedInMapValue + ?Sized, + K: Proxied, + V: ProxiedInMapValue, { fn default() -> Self { Map::new() @@ -220,8 +211,8 @@ impl<'msg, K: ?Sized, V: ?Sized> MapView<'msg, K, V> { impl<'msg, K, V> MapView<'msg, K, V> where - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { pub fn get<'a>(self, key: impl Into>) -> Option> where @@ -278,8 +269,8 @@ impl<'msg, K: ?Sized, V: ?Sized> MapMut<'msg, K, V> { impl<'msg, K, V> MapMut<'msg, K, V> where - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { pub fn len(&self) -> usize { self.as_view().len() @@ -378,8 +369,8 @@ impl<'msg, K: ?Sized, V: ?Sized> MapIter<'msg, K, V> { impl<'msg, K, V> Iterator for MapIter<'msg, K, V> where - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { type Item = (View<'msg, K>, View<'msg, V>); @@ -390,8 +381,8 @@ where impl<'msg, K, V> IntoIterator for MapView<'msg, K, V> where - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { type IntoIter = MapIter<'msg, K, V>; type Item = (View<'msg, K>, View<'msg, V>); @@ -403,8 +394,8 @@ where impl<'msg, K, V> IntoIterator for &'msg Map where - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { type IntoIter = MapIter<'msg, K, V>; type Item = (View<'msg, K>, View<'msg, V>); @@ -417,8 +408,8 @@ where impl<'a, 'msg, K, V> IntoIterator for &'a MapView<'msg, K, V> where 'msg: 'a, - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { type IntoIter = MapIter<'msg, K, V>; type Item = (View<'msg, K>, View<'msg, V>); @@ -431,8 +422,8 @@ where impl<'a, 'msg, K, V> IntoIterator for &'a MapMut<'msg, K, V> where 'msg: 'a, - K: Proxied + ?Sized + 'msg, - V: ProxiedInMapValue + ?Sized + 'msg, + K: Proxied + 'msg, + V: ProxiedInMapValue + 'msg, { type IntoIter = MapIter<'a, K, V>; // The View's are valid for 'a instead of 'msg. @@ -446,8 +437,8 @@ where impl<'msg, 'k, 'v, KView, VView, K, V> Extend<(KView, VView)> for MapMut<'msg, K, V> where - K: Proxied + ?Sized + 'msg + 'k, - V: ProxiedInMapValue + ?Sized + 'msg + 'v, + K: Proxied + 'msg + 'k, + V: ProxiedInMapValue + 'msg + 'v, KView: Into>, VView: IntoProxied, { diff --git a/rust/proxied.rs b/rust/proxied.rs index 5606824441..f252b2e879 100644 --- a/rust/proxied.rs +++ b/rust/proxied.rs @@ -96,7 +96,7 @@ pub type Mut<'msg, T> = ::Mut<'msg>; /// This trait is intentionally made non-object-safe to prevent a potential /// future incompatible change. pub trait Proxy<'msg>: 'msg + Sync + Unpin + Sized + Debug { - type Proxied: 'msg + Proxied + ?Sized; + type Proxied: 'msg + Proxied; /// Converts a borrow into a `View` with the lifetime of that borrow. /// diff --git a/rust/upb.rs b/rust/upb.rs index 82798965dd..0af32ba382 100644 --- a/rust/upb.rs +++ b/rust/upb.rs @@ -464,7 +464,7 @@ pub fn free_enum_repeated( } /// Returns a static empty RepeatedView. -pub fn empty_array() -> RepeatedView<'static, T> { +pub fn empty_array() -> RepeatedView<'static, T> { // TODO: Consider creating a static empty array in C. // Use `i32` for a shared empty repeated for all repeated types in the program. @@ -484,8 +484,8 @@ pub fn empty_array() -> RepeatedView<'static, T> /// Returns a static empty MapView. pub fn empty_map() -> MapView<'static, K, V> where - K: Proxied + ?Sized, - V: ProxiedInMapValue + ?Sized, + K: Proxied, + V: ProxiedInMapValue, { // TODO: Consider creating a static empty map in C.