diff --git a/rust/cpp.rs b/rust/cpp.rs index d5743f6ad4..2090a662f9 100644 --- a/rust/cpp.rs +++ b/rust/cpp.rs @@ -141,7 +141,7 @@ impl fmt::Debug for SerializedData { pub type BytesPresentMutData<'msg> = crate::vtable::RawVTableOptionalMutatorData<'msg, [u8]>; pub type BytesAbsentMutData<'msg> = crate::vtable::RawVTableOptionalMutatorData<'msg, [u8]>; pub type InnerBytesMut<'msg> = crate::vtable::RawVTableMutator<'msg, [u8]>; -pub type InnerPrimitiveMut<'a, T> = crate::vtable::RawVTableMutator<'a, T>; +pub type InnerPrimitiveMut<'msg, T> = crate::vtable::RawVTableMutator<'msg, T>; /// The raw contents of every generated message. #[derive(Debug)] @@ -187,10 +187,10 @@ impl<'msg> MutatorMessageRef<'msg> { } } -pub fn copy_bytes_in_arena_if_needed_by_runtime<'a>( - _msg_ref: MutatorMessageRef<'a>, - val: &'a [u8], -) -> &'a [u8] { +pub fn copy_bytes_in_arena_if_needed_by_runtime<'msg>( + _msg_ref: MutatorMessageRef<'msg>, + val: &'msg [u8], +) -> &'msg [u8] { // Nothing to do, the message manages its own string memory for C++. val } @@ -341,14 +341,14 @@ macro_rules! generate_map_with_key_ops_traits { paste! { $( pub trait [< MapWith $t:camel KeyOps >] { - type Value<'a>: Sized; + type Value<'msg>: Sized; fn new_map() -> RawMap; fn clear(m: RawMap); fn size(m: RawMap) -> usize; fn insert(m: RawMap, key: $sized_t, value: Self::Value<'_>) -> bool; - fn get<'a>(m: RawMap, key: $sized_t) -> Option>; - fn remove<'a>(m: RawMap, key: $sized_t) -> bool; + fn get<'msg>(m: RawMap, key: $sized_t) -> Option>; + fn remove(m: RawMap, key: $sized_t) -> bool; } impl<'msg, V: [< MapWith $t:camel KeyOps >] + ?Sized> Default for MapInner<'msg, $t, V> { @@ -374,7 +374,7 @@ macro_rules! generate_map_with_key_ops_traits { V::get(self.raw, key) } - pub fn remove<'a>(&mut self, key: $sized_t) -> bool { + pub fn remove(&mut self, key: $sized_t) -> bool { V::remove(self.raw, key) } @@ -409,7 +409,7 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values { fn [< __pb_rust_Map_ $key_t _ $t _remove >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool; } impl $trait for $t { - type Value<'a> = $sized_t; + type Value<'msg> = $sized_t; fn new_map() -> RawMap { unsafe { [< __pb_rust_Map_ $key_t _ $t _new >]() } @@ -430,7 +430,7 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values { true } - fn get<'a>(m: RawMap, key: $sized_key_t) -> Option> { + fn get<'msg>(m: RawMap, key: $sized_key_t) -> Option> { let ffi_key = $to_ffi_key(key); let mut ffi_value = $to_ffi_value($zero_val); let found = unsafe { [< __pb_rust_Map_ $key_t _ $t _get >](m, ffi_key, &mut ffi_value) }; @@ -440,7 +440,7 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values { Some($from_ffi_value(ffi_value)) } - fn remove<'a>(m: RawMap, key: $sized_key_t) -> bool { + fn remove(m: RawMap, key: $sized_key_t) -> bool { let ffi_key = $to_ffi_key(key); let mut ffi_value = $to_ffi_value($zero_val); unsafe { [< __pb_rust_Map_ $key_t _ $t _remove >](m, ffi_key, &mut ffi_value) } @@ -450,11 +450,11 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values { } } -fn str_to_ptrlen<'a>(val: impl Into<&'a ProtoStr>) -> PtrAndLen { +fn str_to_ptrlen<'msg>(val: impl Into<&'msg ProtoStr>) -> PtrAndLen { val.into().as_bytes().into() } -fn ptrlen_to_str<'a>(val: PtrAndLen) -> &'a ProtoStr { +fn ptrlen_to_str<'msg>(val: PtrAndLen) -> &'msg ProtoStr { unsafe { ProtoStr::from_utf8_unchecked(val.as_ref()) } } @@ -470,7 +470,7 @@ macro_rules! impl_map_with_key_ops_for_scalar_values { i64, i64, i64, identity, identity, 0i64; u64, u64, u64, identity, identity, 0u64; bool, bool, bool, identity, identity, false; - ProtoStr, &'a ProtoStr, PtrAndLen, str_to_ptrlen, ptrlen_to_str, ""; + ProtoStr, &'msg ProtoStr, PtrAndLen, str_to_ptrlen, ptrlen_to_str, ""; ); )* } diff --git a/rust/map.rs b/rust/map.rs index 9f6a11ce35..795c107571 100644 --- a/rust/map.rs +++ b/rust/map.rs @@ -17,27 +17,27 @@ use paste::paste; use std::marker::PhantomData; #[repr(transparent)] -pub struct MapView<'a, K: ?Sized, V: ?Sized> { - inner: MapInner<'a, K, V>, +pub struct MapView<'msg, K: ?Sized, V: ?Sized> { + inner: MapInner<'msg, K, V>, } -impl<'a, K: ?Sized, V: ?Sized> MapView<'a, K, V> { - pub fn from_inner(_private: Private, inner: MapInner<'a, K, V>) -> Self { +impl<'msg, K: ?Sized, V: ?Sized> MapView<'msg, K, V> { + pub fn from_inner(_private: Private, inner: MapInner<'msg, K, V>) -> Self { Self { inner } } } -impl<'a, K: ?Sized, V: ?Sized> Copy for MapView<'a, K, V> {} -impl<'a, K: ?Sized, V: ?Sized> Clone for MapView<'a, K, V> { +impl<'msg, K: ?Sized, V: ?Sized> Copy for MapView<'msg, K, V> {} +impl<'msg, K: ?Sized, V: ?Sized> Clone for MapView<'msg, K, V> { fn clone(&self) -> Self { *self } } -unsafe impl<'a, K: ?Sized, V: ?Sized> Sync for MapView<'a, K, V> {} -unsafe impl<'a, K: ?Sized, V: ?Sized> Send for MapView<'a, K, V> {} +unsafe impl<'msg, K: ?Sized, V: ?Sized> Sync for MapView<'msg, K, V> {} +unsafe impl<'msg, K: ?Sized, V: ?Sized> Send for MapView<'msg, K, V> {} -impl<'a, K: ?Sized, V: ?Sized> std::fmt::Debug for MapView<'a, K, V> { +impl<'msg, K: ?Sized, V: ?Sized> std::fmt::Debug for MapView<'msg, K, V> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("MapView") .field(&std::any::type_name::()) @@ -47,19 +47,19 @@ impl<'a, K: ?Sized, V: ?Sized> std::fmt::Debug for MapView<'a, K, V> { } #[repr(transparent)] -pub struct MapMut<'a, K: ?Sized, V: ?Sized> { - inner: MapInner<'a, K, V>, +pub struct MapMut<'msg, K: ?Sized, V: ?Sized> { + inner: MapInner<'msg, K, V>, } -impl<'a, K: ?Sized, V: ?Sized> MapMut<'a, K, V> { - pub fn from_inner(_private: Private, inner: MapInner<'a, K, V>) -> Self { +impl<'msg, K: ?Sized, V: ?Sized> MapMut<'msg, K, V> { + pub fn from_inner(_private: Private, inner: MapInner<'msg, K, V>) -> Self { Self { inner } } } -unsafe impl<'a, K: ?Sized, V: ?Sized> Sync for MapMut<'a, K, V> {} +unsafe impl<'msg, K: ?Sized, V: ?Sized> Sync for MapMut<'msg, K, V> {} -impl<'a, K: ?Sized, V: ?Sized> std::fmt::Debug for MapMut<'a, K, V> { +impl<'msg, K: ?Sized, V: ?Sized> std::fmt::Debug for MapMut<'msg, K, V> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("MapMut") .field(&std::any::type_name::()) @@ -68,14 +68,14 @@ impl<'a, K: ?Sized, V: ?Sized> std::fmt::Debug for MapMut<'a, K, V> { } } -impl<'a, K: ?Sized, V: ?Sized> std::ops::Deref for MapMut<'a, K, V> { - type Target = MapView<'a, K, V>; +impl<'msg, K: ?Sized, V: ?Sized> std::ops::Deref for MapMut<'msg, K, V> { + type Target = MapView<'msg, K, V>; fn deref(&self) -> &Self::Target { // SAFETY: - // - `Map{View,Mut}<'a, T>` are both `#[repr(transparent)]` over `MapInner<'a, - // T>`. + // - `Map{View,Mut}<'msg, T>` are both `#[repr(transparent)]` over + // `MapInner<'msg, T>`. // - `MapInner` is a type alias for `NonNull`. - unsafe { &*(self as *const Self as *const MapView<'a, K, V>) } + unsafe { &*(self as *const Self as *const MapView<'msg, K, V>) } } } @@ -87,11 +87,11 @@ macro_rules! impl_proxied_for_map_keys { ($(key_type $t:ty;)*) => { paste! { $( impl] + Proxied + ?Sized> Proxied for Map<$t, V>{ - type View<'a> = MapView<'a, $t, V> where V: 'a; - type Mut<'a> = MapMut<'a, $t, V> where V: 'a; + type View<'msg> = MapView<'msg, $t, V> where V: 'msg; + type Mut<'msg> = MapMut<'msg, $t, V> where V: 'msg; } - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> SettableValue> for MapView<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> SettableValue> for MapView<'msg, $t, V> { fn set_on<'b>(self, _private: Private, mut mutator: Mut<'b, Map<$t, V>>) where Map<$t, V>: 'b { @@ -99,7 +99,7 @@ macro_rules! impl_proxied_for_map_keys { } } - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> ViewProxy<'a> for MapView<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> ViewProxy<'msg> for MapView<'msg, $t, V> { type Proxied = Map<$t, V>; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -107,13 +107,13 @@ macro_rules! impl_proxied_for_map_keys { } fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { MapView { inner: self.inner } } } - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> ViewProxy<'a> for MapMut<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> ViewProxy<'msg> for MapMut<'msg, $t, V> { type Proxied = Map<$t, V>; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -121,19 +121,19 @@ macro_rules! impl_proxied_for_map_keys { } fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { *self.into_mut::<'shorter>() } } - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> MutProxy<'a> for MapMut<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MutProxy<'msg> for MapMut<'msg, $t, V> { fn as_mut(&mut self) -> Mut<'_, Self::Proxied> { MapMut { inner: self.inner } } fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { MapMut { inner: self.inner } } @@ -154,7 +154,7 @@ impl_proxied_for_map_keys!( macro_rules! impl_scalar_map_keys { ($(key_type $t:ty;)*) => { paste! { $( - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> MapView<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MapView<'msg, $t, V> { pub fn get<'b>(&self, key: $t) -> Option> { self.inner.get(key) } @@ -168,7 +168,7 @@ macro_rules! impl_scalar_map_keys { } } - impl<'a, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'a> MapMut<'a, $t, V> { + impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MapMut<'msg, $t, V> { pub fn insert(&mut self, key: $t, value: V::Value<'_>) -> bool { self.inner.insert(key, value) } @@ -197,8 +197,8 @@ impl_scalar_map_keys!( key_type bool; ); -impl<'a, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'a> MapView<'a, ProtoStr, V> { - pub fn get(&self, key: impl Into<&'a ProtoStr>) -> Option> { +impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapView<'msg, ProtoStr, V> { + pub fn get(&self, key: impl Into<&'msg ProtoStr>) -> Option> { self.inner.get(key.into()) } @@ -211,12 +211,12 @@ impl<'a, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'a> MapView<'a, ProtoStr, } } -impl<'a, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'a> MapMut<'a, ProtoStr, V> { - pub fn insert(&mut self, key: impl Into<&'a ProtoStr>, value: V::Value<'_>) -> bool { +impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapMut<'msg, ProtoStr, V> { + pub fn insert(&mut self, key: impl Into<&'msg ProtoStr>, value: V::Value<'_>) -> bool { self.inner.insert(key.into(), value) } - pub fn remove(&mut self, key: impl Into<&'a ProtoStr>) -> bool { + pub fn remove(&mut self, key: impl Into<&'msg ProtoStr>) -> bool { self.inner.remove(key.into()) } diff --git a/rust/optional.rs b/rust/optional.rs index ba9955b62c..0268c61bfd 100644 --- a/rust/optional.rs +++ b/rust/optional.rs @@ -83,7 +83,7 @@ impl From> for Option { /// A mutable view into the value of an optional field, which may be set or /// unset. -pub type FieldEntry<'a, T> = Optional, AbsentField<'a, T>>; +pub type FieldEntry<'msg, T> = Optional, AbsentField<'msg, T>>; /// Methods for `_mut()` accessors of optional types. /// @@ -285,11 +285,11 @@ where /// A field mutator capable of setting that is statically known to point to a /// non-set field. -pub struct AbsentField<'a, T> +pub struct AbsentField<'msg, T> where - T: ProxiedWithPresence + ?Sized + 'a, + T: ProxiedWithPresence + ?Sized + 'msg, { - pub(crate) inner: T::AbsentMutData<'a>, + pub(crate) inner: T::AbsentMutData<'msg>, } impl<'msg, T: ProxiedWithPresence + ?Sized + 'msg> Debug for AbsentField<'msg, T> { @@ -432,10 +432,10 @@ mod tests { } } - fn make_field_entry<'a>( - msg: &'a mut MyMessage, - vtable: &'a ProxyVtable, - ) -> FieldEntry<'a, VtableProxied> { + fn make_field_entry<'msg>( + msg: &'msg mut MyMessage, + vtable: &'msg ProxyVtable, + ) -> FieldEntry<'msg, VtableProxied> { if (vtable.has)(&*msg) { Optional::Set(PresentField::from_inner(Private, VtableProxiedMut { msg, vtable })) } else { @@ -494,8 +494,8 @@ mod tests { struct VtableProxied; impl Proxied for VtableProxied { - type View<'a> = VtableProxiedView; - type Mut<'a> = VtableProxiedMut<'a>; + type View<'msg> = VtableProxiedView; + type Mut<'msg> = VtableProxiedMut<'msg>; } impl ProxiedWithPresence for VtableProxied { @@ -503,19 +503,19 @@ mod tests { // `Mut` in layout. Other types/runtimes could require otherwise, e.g. `Mut` // could be defined to only have get/set functions in its vtable, and not // has/clear. - type PresentMutData<'a> = VtableProxiedMut<'a>; - type AbsentMutData<'a> = VtableProxiedMut<'a>; + type PresentMutData<'msg> = VtableProxiedMut<'msg>; + type AbsentMutData<'msg> = VtableProxiedMut<'msg>; - fn clear_present_field<'a>( - present_mutator: Self::PresentMutData<'a>, - ) -> Self::AbsentMutData<'a> { + fn clear_present_field<'msg>( + present_mutator: Self::PresentMutData<'msg>, + ) -> Self::AbsentMutData<'msg> { (present_mutator.vtable.clear)(&mut *present_mutator.msg); present_mutator } - fn set_absent_to_default<'a>( - absent_mutator: Self::AbsentMutData<'a>, - ) -> Self::PresentMutData<'a> { + fn set_absent_to_default<'msg>( + absent_mutator: Self::AbsentMutData<'msg>, + ) -> Self::PresentMutData<'msg> { SettableValue::::set_on_absent( absent_mutator.as_view().val(), Private, @@ -539,28 +539,28 @@ mod tests { } } - impl<'a> ViewProxy<'a> for VtableProxiedView { + impl<'msg> ViewProxy<'msg> for VtableProxiedView { type Proxied = VtableProxied; - fn as_view(&self) -> View<'a, VtableProxied> { + fn as_view(&self) -> View<'msg, VtableProxied> { *self } fn into_view<'shorter>(self) -> View<'shorter, VtableProxied> where - 'a: 'shorter, + 'msg: 'shorter, { self } } #[derive(Debug)] - struct VtableProxiedMut<'a> { - msg: &'a mut MyMessage, - vtable: &'a ProxyVtable, + struct VtableProxiedMut<'msg> { + msg: &'msg mut MyMessage, + vtable: &'msg ProxyVtable, } - impl<'a> ViewProxy<'a> for VtableProxiedMut<'a> { + impl<'msg> ViewProxy<'msg> for VtableProxiedMut<'msg> { type Proxied = VtableProxied; fn as_view(&self) -> View<'_, VtableProxied> { @@ -569,55 +569,55 @@ mod tests { fn into_view<'shorter>(self) -> View<'shorter, VtableProxied> where - 'a: 'shorter, + 'msg: 'shorter, { VtableProxiedView::read(self.msg, self.vtable) } } - impl<'a> MutProxy<'a> for VtableProxiedMut<'a> { + impl<'msg> MutProxy<'msg> for VtableProxiedMut<'msg> { fn as_mut(&mut self) -> Mut<'_, VtableProxied> { VtableProxiedMut { msg: self.msg, vtable: self.vtable } } fn into_mut<'shorter>(self) -> Mut<'shorter, VtableProxied> where - 'a: 'shorter, + 'msg: 'shorter, { self } } impl SettableValue for View<'_, VtableProxied> { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, VtableProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, VtableProxied>) where - VtableProxied: 'a, + VtableProxied: 'msg, { SettableValue::::set_on(self.val(), Private, mutator) } - fn set_on_absent<'a>( + fn set_on_absent<'msg>( self, _private: Private, - absent_mutator: ::AbsentMutData<'a>, - ) -> ::PresentMutData<'a> { + absent_mutator: ::AbsentMutData<'msg>, + ) -> ::PresentMutData<'msg> { SettableValue::::set_on_absent(self.val(), Private, absent_mutator) } } impl SettableValue for i32 { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, VtableProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, VtableProxied>) where - VtableProxied: 'a, + VtableProxied: 'msg, { (mutator.vtable.set)(mutator.msg, self) } - fn set_on_absent<'a>( + fn set_on_absent<'msg>( self, _private: Private, - absent_mutator: ::AbsentMutData<'a>, - ) -> ::PresentMutData<'a> { + absent_mutator: ::AbsentMutData<'msg>, + ) -> ::PresentMutData<'msg> { (absent_mutator.vtable.set)(absent_mutator.msg, self); absent_mutator } diff --git a/rust/primitive.rs b/rust/primitive.rs index 0b81d2e2e9..bf4d63268b 100644 --- a/rust/primitive.rs +++ b/rust/primitive.rs @@ -14,28 +14,28 @@ use crate::vtable::{ use crate::{Mut, MutProxy, Proxied, ProxiedWithPresence, SettableValue, View, ViewProxy}; #[derive(Debug)] -pub struct PrimitiveMut<'a, T: ProxiedWithRawVTable> { - inner: InnerPrimitiveMut<'a, T>, +pub struct PrimitiveMut<'msg, T: ProxiedWithRawVTable> { + inner: InnerPrimitiveMut<'msg, T>, } -impl<'a, T: ProxiedWithRawVTable> PrimitiveMut<'a, T> { +impl<'msg, T: ProxiedWithRawVTable> PrimitiveMut<'msg, T> { #[doc(hidden)] - pub fn from_inner(_private: Private, inner: InnerPrimitiveMut<'a, T>) -> Self { + pub fn from_inner(_private: Private, inner: InnerPrimitiveMut<'msg, T>) -> Self { Self { inner } } } -unsafe impl<'a, T: ProxiedWithRawVTable> Sync for PrimitiveMut<'a, T> {} +unsafe impl<'msg, T: ProxiedWithRawVTable> Sync for PrimitiveMut<'msg, T> {} macro_rules! impl_singular_primitives { ($($t:ty),*) => { $( impl Proxied for $t { - type View<'a> = $t; - type Mut<'a> = PrimitiveMut<'a, $t>; + type View<'msg> = $t; + type Mut<'msg> = PrimitiveMut<'msg, $t>; } - impl<'a> ViewProxy<'a> for $t { + impl<'msg> ViewProxy<'msg> for $t { type Proxied = $t; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -47,7 +47,7 @@ macro_rules! impl_singular_primitives { } } - impl<'a> PrimitiveMut<'a, $t> { + impl<'msg> PrimitiveMut<'msg, $t> { pub fn get(&self) -> View<'_, $t> { self.inner.get() } @@ -57,7 +57,7 @@ macro_rules! impl_singular_primitives { } } - impl<'a> ViewProxy<'a> for PrimitiveMut<'a, $t> { + impl<'msg> ViewProxy<'msg> for PrimitiveMut<'msg, $t> { type Proxied = $t; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -69,21 +69,21 @@ macro_rules! impl_singular_primitives { } } - impl<'a> MutProxy<'a> for PrimitiveMut<'a, $t> { + impl<'msg> MutProxy<'msg> for PrimitiveMut<'msg, $t> { fn as_mut(&mut self) -> Mut<'_, Self::Proxied> { PrimitiveMut { inner: self.inner } } fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { self } } impl SettableValue<$t> for $t { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, $t>) where $t: 'a { - // SAFETY: the raw mutator is valid for `'a` as enforced by `Mut` + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, $t>) where $t: 'msg { + // SAFETY: the raw mutator is valid for `'msg` as enforced by `Mut` unsafe { mutator.inner.set(self) } } } @@ -104,8 +104,8 @@ macro_rules! impl_singular_primitives { } impl ProxiedWithPresence for $t { - type PresentMutData<'a> = RawVTableOptionalMutatorData<'a, $t>; - type AbsentMutData<'a> = RawVTableOptionalMutatorData<'a, $t>; + type PresentMutData<'msg> = RawVTableOptionalMutatorData<'msg, $t>; + type AbsentMutData<'msg> = RawVTableOptionalMutatorData<'msg, $t>; fn clear_present_field( present_mutator: Self::PresentMutData<'_>, diff --git a/rust/proxied.rs b/rust/proxied.rs index c3da62d639..44bb3e18a0 100644 --- a/rust/proxied.rs +++ b/rust/proxied.rs @@ -55,47 +55,47 @@ use std::marker::{Send, Sync}; /// /// All Protobuf field types implement `Proxied`. pub trait Proxied { - /// The proxy type that provides shared access to a `T`, like a `&'a T`. + /// The proxy type that provides shared access to a `T`, like a `&'msg T`. /// /// Most code should use the type alias [`View`]. - type View<'a>: ViewProxy<'a, Proxied = Self> + Copy + Send + SettableValue + type View<'msg>: ViewProxy<'msg, Proxied = Self> + Copy + Send + SettableValue where - Self: 'a; + Self: 'msg; /// The proxy type that provides exclusive mutable access to a `T`, like a - /// `&'a mut T`. + /// `&'msg mut T`. /// /// Most code should use the type alias [`Mut`]. - type Mut<'a>: MutProxy<'a, Proxied = Self> + type Mut<'msg>: MutProxy<'msg, Proxied = Self> where - Self: 'a; + Self: 'msg; } -/// A proxy type that provides shared access to a `T`, like a `&'a T`. +/// A proxy type that provides shared access to a `T`, like a `&'msg T`. /// /// This is more concise than fully spelling the associated type. #[allow(dead_code)] -pub type View<'a, T> = ::View<'a>; +pub type View<'msg, T> = ::View<'msg>; /// A proxy type that provides exclusive mutable access to a `T`, like a -/// `&'a mut T`. +/// `&'msg mut T`. /// /// This is more concise than fully spelling the associated type. #[allow(dead_code)] -pub type Mut<'a, T> = ::Mut<'a>; +pub type Mut<'msg, T> = ::Mut<'msg>; /// Declares conversion operations common to all views. /// /// This trait is intentionally made non-object-safe to prevent a potential /// future incompatible change. -pub trait ViewProxy<'a>: 'a + Sized + Sync + Unpin + Sized + Debug { - type Proxied: 'a + Proxied + ?Sized; +pub trait ViewProxy<'msg>: 'msg + Sized + Sync + Unpin + Sized + Debug { + type Proxied: 'msg + Proxied + ?Sized; /// Converts a borrow into a `View` with the lifetime of that borrow. /// /// In non-generic code we don't need to use `as_view` because the proxy - /// types are covariant over `'a`. However, generic code conservatively - /// treats `'a` as [invariant], therefore we need to call + /// types are covariant over `'msg`. However, generic code conservatively + /// treats `'msg` as [invariant], therefore we need to call /// `as_view` to explicitly perform the operation that in concrete code /// coercion would perform implicitly. /// @@ -115,8 +115,8 @@ pub trait ViewProxy<'a>: 'a + Sized + Sync + Unpin + Sized + Debug { /// Converts into a `View` with a potentially shorter lifetime. /// /// In non-generic code we don't need to use `into_view` because the proxy - /// types are covariant over `'a`. However, generic code conservatively - /// treats `'a` as [invariant], therefore we need to call + /// types are covariant over `'msg`. However, generic code conservatively + /// treats `'msg` as [invariant], therefore we need to call /// `into_view` to explicitly perform the operation that in concrete /// code coercion would perform implicitly. /// @@ -139,14 +139,14 @@ pub trait ViewProxy<'a>: 'a + Sized + Sync + Unpin + Sized + Debug { /// [invariant]: https://doc.rust-lang.org/nomicon/subtyping.html#variance fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied> where - 'a: 'shorter; + 'msg: 'shorter; } /// Declares operations common to all mutators. /// /// This trait is intentionally made non-object-safe to prevent a potential /// future incompatible change. -pub trait MutProxy<'a>: ViewProxy<'a> { +pub trait MutProxy<'msg>: ViewProxy<'msg> { /// Gets an immutable view of this field. This is shorthand for `as_view`. /// /// This provides a shorter lifetime than `into_view` but can also be called @@ -181,8 +181,8 @@ pub trait MutProxy<'a>: ViewProxy<'a> { /// Converts into a `Mut` with a potentially shorter lifetime. /// /// In non-generic code we don't need to use `into_mut` because the proxy - /// types are covariant over `'a`. However, generic code conservatively - /// treats `'a` as [invariant], therefore we need to call + /// types are covariant over `'msg`. However, generic code conservatively + /// treats `'msg` as [invariant], therefore we need to call /// `into_mut` to explicitly perform the operation that in concrete code /// coercion would perform implicitly. /// @@ -202,7 +202,7 @@ pub trait MutProxy<'a>: ViewProxy<'a> { /// [invariant]: https://doc.rust-lang.org/nomicon/subtyping.html#variance fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied> where - 'a: 'shorter; + 'msg: 'shorter; } /// `Proxied` types that can be optionally set or unset. @@ -211,25 +211,21 @@ pub trait MutProxy<'a>: ViewProxy<'a> { /// types don't. pub trait ProxiedWithPresence: Proxied { /// The data necessary to store a present field mutator proxying `Self`. - /// This is the contents of `PresentField<'a, Self>`. - type PresentMutData<'a>: MutProxy<'a, Proxied = Self>; + /// This is the contents of `PresentField<'msg, Self>`. + type PresentMutData<'msg>: MutProxy<'msg, Proxied = Self>; /// The data necessary to store an absent field mutator proxying `Self`. - /// This is the contents of `AbsentField<'a, Self>`. - type AbsentMutData<'a>: ViewProxy<'a, Proxied = Self>; + /// This is the contents of `AbsentField<'msg, Self>`. + type AbsentMutData<'msg>: ViewProxy<'msg, Proxied = Self>; /// Clears a present field. - fn clear_present_field<'a>( - present_mutator: Self::PresentMutData<'a>, - ) -> Self::AbsentMutData<'a>; + fn clear_present_field(present_mutator: Self::PresentMutData<'_>) -> Self::AbsentMutData<'_>; /// Sets an absent field to its default value. /// /// This can be more efficient than setting with a default value, e.g. /// a default submessage could share resources with the parent message. - fn set_absent_to_default<'a>( - absent_mutator: Self::AbsentMutData<'a>, - ) -> Self::PresentMutData<'a>; + fn set_absent_to_default(absent_mutator: Self::AbsentMutData<'_>) -> Self::PresentMutData<'_>; } /// Values that can be used to set a field of `T`. @@ -239,18 +235,18 @@ where { /// Consumes `self` to set the given mutator to its value. #[doc(hidden)] - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, T>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, T>) where - T: 'a; + T: 'msg; /// Consumes `self` and `absent_mutator` to set the given empty field to /// a value. #[doc(hidden)] - fn set_on_absent<'a>( + fn set_on_absent( self, _private: Private, - absent_mutator: T::AbsentMutData<'a>, - ) -> T::PresentMutData<'a> + absent_mutator: T::AbsentMutData<'_>, + ) -> T::PresentMutData<'_> where T: ProxiedWithPresence, { @@ -291,13 +287,13 @@ mod tests { } impl Proxied for MyProxied { - type View<'a> = MyProxiedView<'a>; - type Mut<'a> = MyProxiedMut<'a>; + type View<'msg> = MyProxiedView<'msg>; + type Mut<'msg> = MyProxiedMut<'msg>; } #[derive(Debug, Clone, Copy)] - struct MyProxiedView<'a> { - my_proxied_ref: &'a MyProxied, + struct MyProxiedView<'msg> { + my_proxied_ref: &'msg MyProxied, } impl MyProxiedView<'_> { @@ -306,27 +302,27 @@ mod tests { } } - impl<'a> ViewProxy<'a> for MyProxiedView<'a> { + impl<'msg> ViewProxy<'msg> for MyProxiedView<'msg> { type Proxied = MyProxied; - fn as_view(&self) -> View<'a, MyProxied> { + fn as_view(&self) -> View<'msg, MyProxied> { *self } fn into_view<'shorter>(self) -> View<'shorter, MyProxied> where - 'a: 'shorter, + 'msg: 'shorter, { self } } #[derive(Debug)] - struct MyProxiedMut<'a> { - my_proxied_ref: &'a mut MyProxied, + struct MyProxiedMut<'msg> { + my_proxied_ref: &'msg mut MyProxied, } - impl<'a> ViewProxy<'a> for MyProxiedMut<'a> { + impl<'msg> ViewProxy<'msg> for MyProxiedMut<'msg> { type Proxied = MyProxied; fn as_view(&self) -> View<'_, MyProxied> { @@ -334,56 +330,56 @@ mod tests { } fn into_view<'shorter>(self) -> View<'shorter, MyProxied> where - 'a: 'shorter, + 'msg: 'shorter, { MyProxiedView { my_proxied_ref: self.my_proxied_ref } } } - impl<'a> MutProxy<'a> for MyProxiedMut<'a> { + impl<'msg> MutProxy<'msg> for MyProxiedMut<'msg> { fn as_mut(&mut self) -> Mut<'_, MyProxied> { MyProxiedMut { my_proxied_ref: self.my_proxied_ref } } fn into_mut<'shorter>(self) -> Mut<'shorter, MyProxied> where - 'a: 'shorter, + 'msg: 'shorter, { self } } impl SettableValue for MyProxiedView<'_> { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, MyProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, MyProxied>) where - MyProxied: 'a, + MyProxied: 'msg, { mutator.my_proxied_ref.val = self.my_proxied_ref.val.clone(); } } impl SettableValue for String { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, MyProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, MyProxied>) where - MyProxied: 'a, + MyProxied: 'msg, { mutator.my_proxied_ref.val = self; } } impl SettableValue for &'_ str { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, MyProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, MyProxied>) where - MyProxied: 'a, + MyProxied: 'msg, { mutator.my_proxied_ref.val.replace_range(.., self); } } impl SettableValue for Cow<'_, str> { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, MyProxied>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, MyProxied>) where - MyProxied: 'a, + MyProxied: 'msg, { match self { Cow::Owned(x) => >::set_on(x, Private, mutator), @@ -413,7 +409,7 @@ mod tests { assert_eq!(my_proxied.val, "Hello indeed"); } - fn reborrow_mut_into_view<'a>(x: Mut<'a, MyProxied>) -> View<'a, MyProxied> { + fn reborrow_mut_into_view<'msg>(x: Mut<'msg, MyProxied>) -> View<'msg, MyProxied> { // x.as_view() fails to compile with: // `ERROR: attempt to return function-local borrowed content` x.into_view() // OK: we return the same lifetime as we got in. @@ -425,7 +421,7 @@ mod tests { reborrow_mut_into_view(my_proxied.as_mut()); } - fn require_unified_lifetimes<'a>(_x: Mut<'a, MyProxied>, _y: View<'a, MyProxied>) {} + fn require_unified_lifetimes<'msg>(_x: Mut<'msg, MyProxied>, _y: View<'msg, MyProxied>) {} #[test] fn test_require_unified_lifetimes() { diff --git a/rust/repeated.rs b/rust/repeated.rs index 19b64bc48e..af0f513408 100644 --- a/rust/repeated.rs +++ b/rust/repeated.rs @@ -19,22 +19,22 @@ use crate::{ }; #[derive(Clone, Copy)] -pub struct RepeatedFieldRef<'a> { +pub struct RepeatedFieldRef<'msg> { pub repeated_field: RawRepeatedField, - pub _phantom: PhantomData<&'a mut ()>, + pub _phantom: PhantomData<&'msg mut ()>, } -unsafe impl<'a> Send for RepeatedFieldRef<'a> {} -unsafe impl<'a> Sync for RepeatedFieldRef<'a> {} +unsafe impl<'msg> Send for RepeatedFieldRef<'msg> {} +unsafe impl<'msg> Sync for RepeatedFieldRef<'msg> {} #[derive(Clone, Copy)] #[repr(transparent)] -pub struct RepeatedView<'a, T: ?Sized> { - inner: RepeatedField<'a, T>, +pub struct RepeatedView<'msg, T: ?Sized> { + inner: RepeatedField<'msg, T>, } -unsafe impl<'a, T: ProxiedWithRawVTable> Sync for RepeatedView<'a, T> {} -unsafe impl<'a, T: ProxiedWithRawVTable> Send for RepeatedView<'a, T> {} +unsafe impl<'msg, T: ProxiedWithRawVTable> Sync for RepeatedView<'msg, T> {} +unsafe impl<'msg, T: ProxiedWithRawVTable> Send for RepeatedView<'msg, T> {} impl<'msg, T: ?Sized> RepeatedView<'msg, T> { pub fn from_inner(_private: Private, inner: RepeatedFieldInner<'msg>) -> Self { @@ -42,12 +42,12 @@ impl<'msg, T: ?Sized> RepeatedView<'msg, T> { } } -pub struct RepeatedFieldIter<'a, T> { - inner: RepeatedField<'a, T>, +pub struct RepeatedFieldIter<'msg, T> { + inner: RepeatedField<'msg, T>, current_index: usize, } -impl<'a, T> std::fmt::Debug for RepeatedView<'a, T> { +impl<'msg, T> std::fmt::Debug for RepeatedView<'msg, T> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_tuple("RepeatedView").finish() } @@ -55,11 +55,11 @@ impl<'a, T> std::fmt::Debug for RepeatedView<'a, T> { #[repr(transparent)] #[derive(Debug)] -pub struct RepeatedMut<'a, T: ?Sized> { - inner: RepeatedField<'a, T>, +pub struct RepeatedMut<'msg, T: ?Sized> { + inner: RepeatedField<'msg, T>, } -unsafe impl<'a, T: ProxiedWithRawVTable> Sync for RepeatedMut<'a, T> {} +unsafe impl<'msg, T: ProxiedWithRawVTable> Sync for RepeatedMut<'msg, T> {} impl<'msg, T: ?Sized> RepeatedMut<'msg, T> { pub fn from_inner(_private: Private, inner: RepeatedFieldInner<'msg>) -> Self { @@ -70,14 +70,14 @@ impl<'msg, T: ?Sized> RepeatedMut<'msg, T> { } } -impl<'a, T> std::ops::Deref for RepeatedMut<'a, T> { - type Target = RepeatedView<'a, T>; +impl<'msg, T> std::ops::Deref for RepeatedMut<'msg, T> { + type Target = RepeatedView<'msg, T>; fn deref(&self) -> &Self::Target { // SAFETY: - // - `Repeated{View,Mut}<'a, T>` are both `#[repr(transparent)]` over - // `RepeatedField<'a, T>`. + // - `Repeated{View,Mut}<'msg, T>` are both `#[repr(transparent)]` over + // `RepeatedField<'msg, T>`. // - `RepeatedField` is a type alias for `NonNull`. - unsafe { &*(self as *const Self as *const RepeatedView<'a, T>) } + unsafe { &*(self as *const Self as *const RepeatedView<'msg, T>) } } } @@ -87,11 +87,11 @@ macro_rules! impl_repeated_primitives { ($($t:ty),*) => { $( impl Proxied for Repeated<$t> { - type View<'a> = RepeatedView<'a, $t>; - type Mut<'a> = RepeatedMut<'a, $t>; + type View<'msg> = RepeatedView<'msg, $t>; + type Mut<'msg> = RepeatedMut<'msg, $t>; } - impl<'a> ViewProxy<'a> for RepeatedView<'a, $t> { + impl<'msg> ViewProxy<'msg> for RepeatedView<'msg, $t> { type Proxied = Repeated<$t>; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -99,13 +99,13 @@ macro_rules! impl_repeated_primitives { } fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { RepeatedView { inner: self.inner } } } - impl<'a> ViewProxy<'a> for RepeatedMut<'a, $t> { + impl<'msg> ViewProxy<'msg> for RepeatedMut<'msg, $t> { type Proxied = Repeated<$t>; fn as_view(&self) -> View<'_, Self::Proxied> { @@ -113,25 +113,25 @@ macro_rules! impl_repeated_primitives { } fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { *self.into_mut::<'shorter>() } } - impl<'a> MutProxy<'a> for RepeatedMut<'a, $t> { + impl<'msg> MutProxy<'msg> for RepeatedMut<'msg, $t> { fn as_mut(&mut self) -> Mut<'_, Self::Proxied> { RepeatedMut { inner: self.inner } } fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied> - where 'a: 'shorter, + where 'msg: 'shorter, { RepeatedMut { inner: self.inner } } } - impl <'a> SettableValue> for RepeatedView<'a, $t> { + impl <'msg> SettableValue> for RepeatedView<'msg, $t> { fn set_on<'b> (self, _private: Private, mut mutator: Mut<'b, Repeated<$t>>) where Repeated<$t>: 'b { @@ -139,7 +139,7 @@ macro_rules! impl_repeated_primitives { } } - impl<'a> RepeatedView<'a, $t> { + impl<'msg> RepeatedView<'msg, $t> { pub fn len(&self) -> usize { self.inner.len() } @@ -154,7 +154,7 @@ macro_rules! impl_repeated_primitives { } } - impl<'a> RepeatedMut<'a, $t> { + impl<'msg> RepeatedMut<'msg, $t> { pub fn push(&mut self, val: $t) { self.inner.push(val) } @@ -169,7 +169,7 @@ macro_rules! impl_repeated_primitives { } } - impl<'a> std::iter::Iterator for RepeatedFieldIter<'a, $t> { + impl<'msg> std::iter::Iterator for RepeatedFieldIter<'msg, $t> { type Item = $t; fn next(&mut self) -> Option { let val = self.inner.get(self.current_index); @@ -180,9 +180,9 @@ macro_rules! impl_repeated_primitives { } } - impl<'a> std::iter::IntoIterator for RepeatedView<'a, $t> { + impl<'msg> std::iter::IntoIterator for RepeatedView<'msg, $t> { type Item = $t; - type IntoIter = RepeatedFieldIter<'a, $t>; + type IntoIter = RepeatedFieldIter<'msg, $t>; fn into_iter(self) -> Self::IntoIter { RepeatedFieldIter { inner: self.inner, current_index: 0 } } diff --git a/rust/string.rs b/rust/string.rs index aece6ba824..dfaa51918f 100644 --- a/rust/string.rs +++ b/rust/string.rs @@ -128,15 +128,11 @@ impl ProxiedWithPresence for [u8] { type PresentMutData<'msg> = BytesPresentMutData<'msg>; type AbsentMutData<'msg> = BytesAbsentMutData<'msg>; - fn clear_present_field<'a>( - present_mutator: Self::PresentMutData<'a>, - ) -> Self::AbsentMutData<'a> { + fn clear_present_field(present_mutator: Self::PresentMutData<'_>) -> Self::AbsentMutData<'_> { present_mutator.clear() } - fn set_absent_to_default<'a>( - absent_mutator: Self::AbsentMutData<'a>, - ) -> Self::PresentMutData<'a> { + fn set_absent_to_default(absent_mutator: Self::AbsentMutData<'_>) -> Self::PresentMutData<'_> { absent_mutator.set_absent_to_default() } } @@ -185,9 +181,9 @@ impl<'msg> MutProxy<'msg> for BytesMut<'msg> { } impl SettableValue<[u8]> for &'_ [u8] { - fn set_on<'a>(self, _private: Private, mutator: Mut<'a, [u8]>) + fn set_on<'msg>(self, _private: Private, mutator: Mut<'msg, [u8]>) where - [u8]: 'a, + [u8]: 'msg, { // SAFETY: this is a `bytes` field with no restriction on UTF-8. unsafe { mutator.inner.set(self) } diff --git a/rust/upb.rs b/rust/upb.rs index 50b67dfd39..f618406467 100644 --- a/rust/upb.rs +++ b/rust/upb.rs @@ -217,7 +217,7 @@ impl fmt::Debug for SerializedData { pub type BytesPresentMutData<'msg> = crate::vtable::RawVTableOptionalMutatorData<'msg, [u8]>; pub type BytesAbsentMutData<'msg> = crate::vtable::RawVTableOptionalMutatorData<'msg, [u8]>; pub type InnerBytesMut<'msg> = crate::vtable::RawVTableMutator<'msg, [u8]>; -pub type InnerPrimitiveMut<'a, T> = crate::vtable::RawVTableMutator<'a, T>; +pub type InnerPrimitiveMut<'msg, T> = crate::vtable::RawVTableMutator<'msg, T>; /// The raw contents of every generated message. #[derive(Debug)] @@ -277,10 +277,10 @@ impl<'msg> MutatorMessageRef<'msg> { } } -pub fn copy_bytes_in_arena_if_needed_by_runtime<'a>( - msg_ref: MutatorMessageRef<'a>, - val: &'a [u8], -) -> &'a [u8] { +pub fn copy_bytes_in_arena_if_needed_by_runtime<'msg>( + msg_ref: MutatorMessageRef<'msg>, + val: &'msg [u8], +) -> &'msg [u8] { // SAFETY: the alignment of `[u8]` is less than `UPB_MALLOC_ALIGN`. let new_alloc = unsafe { msg_ref.arena.alloc(Layout::for_value(val)) }; debug_assert_eq!(new_alloc.len(), val.len()); @@ -515,7 +515,7 @@ macro_rules! generate_map_key_ops_traits { paste! { $( pub trait [< MapWith $t:camel KeyOps >] { - type Value<'a>: Sized; + type Value<'msg>: Sized; fn new_map(a: RawArena) -> RawMap; fn clear(m: RawMap) { @@ -525,8 +525,8 @@ macro_rules! generate_map_key_ops_traits { unsafe { upb_Map_Size(m) } } fn insert(m: RawMap, a: RawArena, key: $sized_t, value: Self::Value<'_>) -> bool; - fn get<'a>(m: RawMap, key: $sized_t) -> Option>; - fn remove<'a>(m: RawMap, key: $sized_t) -> bool; + fn get<'msg>(m: RawMap, key: $sized_t) -> Option>; + fn remove(m: RawMap, key: $sized_t) -> bool; } impl<'msg, V: [< MapWith $t:camel KeyOps >] + ?Sized> MapInner<'msg, $t, V> { @@ -552,7 +552,7 @@ macro_rules! generate_map_key_ops_traits { V::get(self.raw, key) } - pub fn remove<'a>(&mut self, key: $sized_t) -> bool { + pub fn remove(&mut self, key: $sized_t) -> bool { V::remove(self.raw, key) } @@ -578,7 +578,7 @@ macro_rules! impl_scalar_map_key_op_for_scalar_values { ($key_t:ty, $key_msg_val:expr, $key_upb_tag:expr, $trait:ident for $($t:ty, $sized_t:ty, $msg_val:expr, $from_msg_val:expr, $upb_tag:expr, $zero_val:literal;)*) => { $( impl $trait for $t { - type Value<'a> = $sized_t; + type Value<'msg> = $sized_t; fn new_map(a: RawArena) -> RawMap { unsafe { upb_Map_New(a, $key_upb_tag, $upb_tag) } @@ -595,7 +595,7 @@ macro_rules! impl_scalar_map_key_op_for_scalar_values { } } - fn get<'a>(m: RawMap, key: $key_t) -> Option> { + fn get<'msg>(m: RawMap, key: $key_t) -> Option> { let mut val = $msg_val($zero_val); let found = unsafe { upb_Map_Get(m, $key_msg_val(key), &mut val) @@ -606,7 +606,7 @@ macro_rules! impl_scalar_map_key_op_for_scalar_values { Some($from_msg_val(val)) } - fn remove<'a>(m: RawMap, key: $key_t) -> bool { + fn remove(m: RawMap, key: $key_t) -> bool { let mut val = $msg_val($zero_val); unsafe { upb_Map_Delete(m, $key_msg_val(key), &mut val) @@ -629,11 +629,11 @@ macro_rules! scalar_from_msg { }; } -fn str_to_msg<'a>(val: impl Into<&'a ProtoStr>) -> upb_MessageValue { +fn str_to_msg<'msg>(val: impl Into<&'msg ProtoStr>) -> upb_MessageValue { upb_MessageValue { str_val: val.into().as_bytes().into() } } -fn msg_to_str<'a>(msg: upb_MessageValue) -> &'a ProtoStr { +fn msg_to_str<'msg>(msg: upb_MessageValue) -> &'msg ProtoStr { unsafe { ProtoStr::from_utf8_unchecked(msg.str_val.as_ref()) } } @@ -649,7 +649,7 @@ macro_rules! impl_map_key_ops_for_scalar_values { i64, i64, scalar_to_msg!(int64_val), scalar_from_msg!(int64_val), UpbCType::Int64, 0i64; u64, u64, scalar_to_msg!(uint64_val), scalar_from_msg!(uint64_val), UpbCType::UInt64, 0u64; bool, bool, scalar_to_msg!(bool_val), scalar_from_msg!(bool_val), UpbCType::Bool, false; - ProtoStr, &'a ProtoStr, str_to_msg, msg_to_str, UpbCType::String, ""; + ProtoStr, &'msg ProtoStr, str_to_msg, msg_to_str, UpbCType::String, ""; ); )* }