From 63e7cfd31bcea15cf224f55c1213577b6226769a Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Thu, 12 Jun 2025 16:30:48 +0100 Subject: [PATCH] Satisfy mismatched-lifetime-syntaxes lint (nightly) See rust-lang/rust#141787 --- src/hook.rs | 4 ++-- src/state.rs | 12 ++++++------ src/state/raw.rs | 4 ++-- src/string.rs | 6 +++--- src/table.rs | 4 ++-- src/types/app_data.rs | 8 ++++---- src/userdata.rs | 2 +- src/value.rs | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/hook.rs b/src/hook.rs index 4c8c256..e3aef66 100644 --- a/src/hook.rs +++ b/src/hook.rs @@ -86,7 +86,7 @@ impl<'a> Debug<'a> { } /// Corresponds to the `n` what mask. - pub fn names(&self) -> DebugNames { + pub fn names(&self) -> DebugNames<'_> { unsafe { #[cfg(not(feature = "luau"))] mlua_assert!( @@ -113,7 +113,7 @@ impl<'a> Debug<'a> { } /// Corresponds to the `S` what mask. - pub fn source(&self) -> DebugSource { + pub fn source(&self) -> DebugSource<'_> { unsafe { #[cfg(not(feature = "luau"))] mlua_assert!( diff --git a/src/state.rs b/src/state.rs index dbe4c2b..df958dd 100644 --- a/src/state.rs +++ b/src/state.rs @@ -876,7 +876,7 @@ impl Lua { /// not count in the stack). /// /// [`Debug`]: crate::hook::Debug - pub fn inspect_stack(&self, level: usize) -> Option { + pub fn inspect_stack(&self, level: usize) -> Option> { let lua = self.lock(); unsafe { let mut ar: ffi::lua_Debug = mem::zeroed(); @@ -1955,7 +1955,7 @@ impl Lua { /// Panics if the data object of type `T` is currently mutably borrowed. Multiple immutable /// reads can be taken out at the same time. #[track_caller] - pub fn app_data_ref(&self) -> Option> { + pub fn app_data_ref(&self) -> Option> { let guard = self.lock_arc(); let extra = unsafe { &*guard.extra.get() }; extra.app_data.borrow(Some(guard)) @@ -1963,7 +1963,7 @@ impl Lua { /// Tries to get a reference to an application data object stored by [`Lua::set_app_data`] of /// type `T`. - pub fn try_app_data_ref(&self) -> StdResult>, BorrowError> { + pub fn try_app_data_ref(&self) -> StdResult>, BorrowError> { let guard = self.lock_arc(); let extra = unsafe { &*guard.extra.get() }; extra.app_data.try_borrow(Some(guard)) @@ -1976,7 +1976,7 @@ impl Lua { /// /// Panics if the data object of type `T` is currently borrowed. #[track_caller] - pub fn app_data_mut(&self) -> Option> { + pub fn app_data_mut(&self) -> Option> { let guard = self.lock_arc(); let extra = unsafe { &*guard.extra.get() }; extra.app_data.borrow_mut(Some(guard)) @@ -1984,7 +1984,7 @@ impl Lua { /// Tries to get a mutable reference to an application data object stored by /// [`Lua::set_app_data`] of type `T`. - pub fn try_app_data_mut(&self) -> StdResult>, BorrowMutError> { + pub fn try_app_data_mut(&self) -> StdResult>, BorrowMutError> { let guard = self.lock_arc(); let extra = unsafe { &*guard.extra.get() }; extra.app_data.try_borrow_mut(Some(guard)) @@ -2058,7 +2058,7 @@ impl Lua { } #[inline(always)] - pub(crate) fn lock(&self) -> ReentrantMutexGuard { + pub(crate) fn lock(&self) -> ReentrantMutexGuard<'_, RawLua> { let rawlua = self.raw.lock(); #[cfg(feature = "luau")] if unsafe { (*rawlua.extra.get()).running_gc } { diff --git a/src/state/raw.rs b/src/state/raw.rs index b7de97f..5b48f49 100644 --- a/src/state/raw.rs +++ b/src/state/raw.rs @@ -316,7 +316,7 @@ impl RawLua { /// Private version of [`Lua::app_data_ref`] #[track_caller] #[inline] - pub(crate) fn priv_app_data_ref(&self) -> Option> { + pub(crate) fn priv_app_data_ref(&self) -> Option> { let extra = unsafe { &*self.extra.get() }; extra.app_data_priv.borrow(None) } @@ -324,7 +324,7 @@ impl RawLua { /// Private version of [`Lua::app_data_mut`] #[track_caller] #[inline] - pub(crate) fn priv_app_data_mut(&self) -> Option> { + pub(crate) fn priv_app_data_mut(&self) -> Option> { let extra = unsafe { &*self.extra.get() }; extra.app_data_priv.borrow_mut(None) } diff --git a/src/string.rs b/src/string.rs index 6304d48..df9bb81 100644 --- a/src/string.rs +++ b/src/string.rs @@ -43,7 +43,7 @@ impl String { /// # } /// ``` #[inline] - pub fn to_str(&self) -> Result { + pub fn to_str(&self) -> Result> { BorrowedStr::try_from(self) } @@ -102,12 +102,12 @@ impl String { /// # } /// ``` #[inline] - pub fn as_bytes(&self) -> BorrowedBytes { + pub fn as_bytes(&self) -> BorrowedBytes<'_> { BorrowedBytes::from(self) } /// Get the bytes that make up this string, including the trailing nul byte. - pub fn as_bytes_with_nul(&self) -> BorrowedBytes { + pub fn as_bytes_with_nul(&self) -> BorrowedBytes<'_> { let BorrowedBytes { buf, borrow, _lua } = BorrowedBytes::from(self); // Include the trailing nul byte (it's always present but excluded by default) let buf = unsafe { slice::from_raw_parts((*buf).as_ptr(), (*buf).len() + 1) }; diff --git a/src/table.rs b/src/table.rs index 4b62705..83b8cc3 100644 --- a/src/table.rs +++ b/src/table.rs @@ -613,7 +613,7 @@ impl Table { /// ``` /// /// [Lua manual]: http://www.lua.org/manual/5.4/manual.html#pdf-next - pub fn pairs(&self) -> TablePairs { + pub fn pairs(&self) -> TablePairs<'_, K, V> { TablePairs { guard: self.0.lua.lock(), table: self, @@ -678,7 +678,7 @@ impl Table { /// # Ok(()) /// # } /// ``` - pub fn sequence_values(&self) -> TableSequence { + pub fn sequence_values(&self) -> TableSequence<'_, V> { TableSequence { guard: self.0.lua.lock(), table: self, diff --git a/src/types/app_data.rs b/src/types/app_data.rs index 0b4c4ba..0ec7a9f 100644 --- a/src/types/app_data.rs +++ b/src/types/app_data.rs @@ -43,7 +43,7 @@ impl AppData { #[inline] #[track_caller] - pub(crate) fn borrow(&self, guard: Option) -> Option> { + pub(crate) fn borrow(&self, guard: Option) -> Option> { match self.try_borrow(guard) { Ok(data) => data, Err(err) => panic!("already mutably borrowed: {err:?}"), @@ -53,7 +53,7 @@ impl AppData { pub(crate) fn try_borrow( &self, guard: Option, - ) -> Result>, BorrowError> { + ) -> Result>, BorrowError> { let data = unsafe { &*self.container.get() } .get(&TypeId::of::()) .map(|c| c.try_borrow()) @@ -74,7 +74,7 @@ impl AppData { #[inline] #[track_caller] - pub(crate) fn borrow_mut(&self, guard: Option) -> Option> { + pub(crate) fn borrow_mut(&self, guard: Option) -> Option> { match self.try_borrow_mut(guard) { Ok(data) => data, Err(err) => panic!("already borrowed: {err:?}"), @@ -84,7 +84,7 @@ impl AppData { pub(crate) fn try_borrow_mut( &self, guard: Option, - ) -> Result>, BorrowMutError> { + ) -> Result>, BorrowMutError> { let data = unsafe { &*self.container.get() } .get(&TypeId::of::()) .map(|c| c.try_borrow_mut()) diff --git a/src/userdata.rs b/src/userdata.rs index a568485..797d32d 100644 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -1008,7 +1008,7 @@ impl UserDataMetatable { /// The pairs are wrapped in a [`Result`], since they are lazily converted to `V` type. /// /// [`Result`]: crate::Result - pub fn pairs(&self) -> UserDataMetatablePairs { + pub fn pairs(&self) -> UserDataMetatablePairs<'_, V> { UserDataMetatablePairs(self.0.pairs()) } } diff --git a/src/value.rs b/src/value.rs index cfc1325..2edef35 100644 --- a/src/value.rs +++ b/src/value.rs @@ -357,7 +357,7 @@ impl Value { /// If the value is a Lua [`String`], try to convert it to [`BorrowedStr`] or return `None` /// otherwise. #[inline] - pub fn as_str(&self) -> Option { + pub fn as_str(&self) -> Option> { self.as_string().and_then(|s| s.to_str().ok()) } @@ -484,7 +484,7 @@ impl Value { #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] #[doc(hidden)] - pub fn to_serializable(&self) -> SerializableValue { + pub fn to_serializable(&self) -> SerializableValue<'_> { SerializableValue::new(self, Default::default(), None) }