diff --git a/cargo-pgrx/src/command/info.rs b/cargo-pgrx/src/command/info.rs index f673d45cac..84e732a2b2 100644 --- a/cargo-pgrx/src/command/info.rs +++ b/cargo-pgrx/src/command/info.rs @@ -78,7 +78,7 @@ impl CommandExecute for Info { } } -fn version(ver: &str) -> Cow { +fn version(ver: &str) -> Cow<'_, str> { if ver.starts_with("pg") { Cow::Borrowed(ver) } else { diff --git a/cargo-pgrx/src/command/schema.rs b/cargo-pgrx/src/command/schema.rs index 9b4a951396..21d8aa1d97 100644 --- a/cargo-pgrx/src/command/schema.rs +++ b/cargo-pgrx/src/command/schema.rs @@ -594,7 +594,7 @@ fn compute_sql(package_name: &str, manifest: &Manifest) -> eyre::Result<()> { Ok(()) } -fn parse_object(data: &[u8]) -> object::Result { +fn parse_object(data: &[u8]) -> object::Result> { let kind = object::FileKind::parse(data)?; match kind { diff --git a/pgrx-macros/src/lib.rs b/pgrx-macros/src/lib.rs index 37c70bdfcc..b070451806 100644 --- a/pgrx-macros/src/lib.rs +++ b/pgrx-macros/src/lib.rs @@ -967,7 +967,7 @@ fn impl_postgres_type(ast: DeriveInput) -> syn::Result #[::pgrx::pgrx_macros::pg_extern(immutable,parallel_safe)] pub fn #funcname_in #generics(input: Option<&::core::ffi::CStr>) -> Option<#name #generics> { input.map_or_else(|| { - for m in <#name as ::pgrx::inoutfuncs::InOutFuncs>::NULL_ERROR_MESSAGE { + if let Some(m) = <#name as ::pgrx::inoutfuncs::InOutFuncs>::NULL_ERROR_MESSAGE { ::pgrx::pg_sys::error!("{m}"); } None @@ -990,7 +990,7 @@ fn impl_postgres_type(ast: DeriveInput) -> syn::Result #[::pgrx::pgrx_macros::pg_extern(immutable,parallel_safe)] pub fn #funcname_in #generics(input: Option<&::core::ffi::CStr>) -> Option<::pgrx::datum::PgVarlena<#name #generics>> { input.map_or_else(|| { - for m in <#name as ::pgrx::inoutfuncs::PgVarlenaInOutFuncs>::NULL_ERROR_MESSAGE { + if let Some(m) = <#name as ::pgrx::inoutfuncs::PgVarlenaInOutFuncs>::NULL_ERROR_MESSAGE { ::pgrx::pg_sys::error!("{m}"); } None diff --git a/pgrx-pg-sys/src/include.rs b/pgrx-pg-sys/src/include.rs index 0e35f07bc2..08b979df32 100644 --- a/pgrx-pg-sys/src/include.rs +++ b/pgrx-pg-sys/src/include.rs @@ -5,6 +5,7 @@ #[cfg(all(feature = "pg13", not(docsrs)))] pub(crate) mod pg13 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg13.rs")); } #[cfg(all(feature = "pg13", docsrs))] @@ -13,6 +14,7 @@ pub(crate) mod pg13; #[cfg(all(feature = "pg14", not(docsrs)))] pub(crate) mod pg14 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg14.rs")); } #[cfg(all(feature = "pg14", docsrs))] @@ -21,6 +23,7 @@ pub(crate) mod pg14; #[cfg(all(feature = "pg15", not(docsrs)))] pub(crate) mod pg15 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg15.rs")); } #[cfg(all(feature = "pg15", docsrs))] @@ -29,6 +32,7 @@ pub(crate) mod pg15; #[cfg(all(feature = "pg16", not(docsrs)))] pub(crate) mod pg16 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg16.rs")); } #[cfg(all(feature = "pg16", docsrs))] @@ -37,6 +41,7 @@ pub(crate) mod pg16; #[cfg(all(feature = "pg17", not(docsrs)))] pub(crate) mod pg17 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg17.rs")); } #[cfg(all(feature = "pg17", docsrs))] @@ -45,6 +50,7 @@ pub(crate) mod pg17; #[cfg(all(feature = "pg18", not(docsrs)))] pub(crate) mod pg18 { #![allow(clippy::all)] + #![allow(unknown_lints, unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/pg18.rs")); } #[cfg(all(feature = "pg18", docsrs))] diff --git a/pgrx-tests/src/tests/hooks_tests.rs b/pgrx-tests/src/tests/hooks_tests.rs index 05dfe3961a..36bfc170f0 100644 --- a/pgrx-tests/src/tests/hooks_tests.rs +++ b/pgrx-tests/src/tests/hooks_tests.rs @@ -7,6 +7,8 @@ //LICENSE All rights reserved. //LICENSE //LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file. +#![allow(deprecated, static_mut_refs)] + #[cfg(any(test, feature = "pg_test"))] #[pgrx::pg_schema] mod tests { diff --git a/pgrx-tests/src/tests/trigger_tests.rs b/pgrx-tests/src/tests/trigger_tests.rs index a92b16b635..14b724a0fd 100644 --- a/pgrx-tests/src/tests/trigger_tests.rs +++ b/pgrx-tests/src/tests/trigger_tests.rs @@ -74,7 +74,9 @@ mod tests { } #[pg_trigger] - fn signature_aliased_both(_trigger: AliasedBorrowedPgTrigger) -> AliasedTriggerResult<'_> { + fn signature_aliased_both( + _trigger: AliasedBorrowedPgTrigger<'_>, + ) -> AliasedTriggerResult<'_> { unimplemented!("Only testing signature compiles") } } diff --git a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.rs b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.rs index b92efcaa34..7c0577bfc9 100644 --- a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.rs +++ b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.rs @@ -3,7 +3,7 @@ use pgrx::prelude::*; #[pg_extern] fn returns_tuple_with_lifetime( value: &'static str, -) -> TableIterator<(name!(a, &'static str), name!(b, Option<&'static str>))> { +) -> TableIterator<'static, (name!(a, &'static str), name!(b, Option<&'static str>))> { TableIterator::once((value, Some(value))) } diff --git a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr index 331cb9420c..d8e1536eb1 100644 --- a/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr +++ b/pgrx-tests/tests/compile-fail/table-iterators-arent-immortal.stderr @@ -1,17 +1,5 @@ -warning: elided lifetime has a name - --> tests/compile-fail/table-iterators-arent-immortal.rs:6:19 - | -6 | ) -> TableIterator<(name!(a, &'static str), name!(b, Option<&'static str>))> { - | ^ this elided lifetime gets resolved as `'static` - | - = note: `#[warn(elided_named_lifetimes)]` on by default -help: consider specifying it explicitly - | -6 | ) -> TableIterator<'static, (name!(a, &'static str), name!(b, Option<&'static str>))> { - | ++++++++ - error[E0521]: borrowed data escapes outside of function - --> tests/compile-fail/table-iterators-arent-immortal.rs:6:78 + --> tests/compile-fail/table-iterators-arent-immortal.rs:6:87 | 3 | #[pg_extern] | ------------ @@ -19,8 +7,8 @@ error[E0521]: borrowed data escapes outside of function | lifetime `'fcx` defined here | in this procedural macro expansion ... -6 | ) -> TableIterator<(name!(a, &'static str), name!(b, Option<&'static str>))> { - | ______________________________________________________________________________^ +6 | ) -> TableIterator<'static, (name!(a, &'static str), name!(b, Option<&'static str>))> { + | _______________________________________________________________________________________^ 7 | | TableIterator::once((value, Some(value))) 8 | | } | | ^ diff --git a/pgrx/src/datum/into.rs b/pgrx/src/datum/into.rs index 31d6d6bb1c..4d8bc82d38 100644 --- a/pgrx/src/datum/into.rs +++ b/pgrx/src/datum/into.rs @@ -378,7 +378,7 @@ impl<'a> IntoDatum for &'a [u8] { // and the `dest` was freshly allocated, thus non-overlapping std::ptr::copy_nonoverlapping( self.as_ptr(), - addr_of_mut!((*varattrib_4b).va_data).cast::(), + addr_of_mut!((&mut *varattrib_4b).va_data).cast::(), self.len(), ); diff --git a/pgrx/src/fn_call.rs b/pgrx/src/fn_call.rs index bf1f2ccabb..37b769e7ce 100644 --- a/pgrx/src/fn_call.rs +++ b/pgrx/src/fn_call.rs @@ -410,7 +410,7 @@ fn lookup_fn(fname: &str, args: &[&dyn FnCallArg]) -> Result { /// Parses an arbitrary string as if it is a SQL identifier. If it's not, [`FnCallError::InvalidIdentifier`] /// is returned -fn parse_sql_ident(ident: &str) -> Result> { +fn parse_sql_ident(ident: &str) -> Result> { unsafe { direct_function_call::>( pg_sys::parse_ident, diff --git a/pgrx/src/lwlock.rs b/pgrx/src/lwlock.rs index c6e7827e5e..99889d837a 100644 --- a/pgrx/src/lwlock.rs +++ b/pgrx/src/lwlock.rs @@ -51,7 +51,7 @@ impl PgLwLock { } /// Obtain a shared lock (which comes with `&T` access) - pub fn share(&self) -> PgLwLockShareGuard { + pub fn share(&self) -> PgLwLockShareGuard<'_, T> { unsafe { let shared = self.inner.get().read().as_ref().expect("PgLwLock was not initialized"); pg_sys::LWLockAcquire((*shared).lock_ptr, pg_sys::LWLockMode::LW_SHARED); @@ -60,7 +60,7 @@ impl PgLwLock { } /// Obtain an exclusive lock (which comes with `&mut T` access) - pub fn exclusive(&self) -> PgLwLockExclusiveGuard { + pub fn exclusive(&self) -> PgLwLockExclusiveGuard<'_, T> { unsafe { let shared = self.inner.get().read().as_ref().expect("PgLwLock was not initialized"); pg_sys::LWLockAcquire((*shared).lock_ptr, pg_sys::LWLockMode::LW_EXCLUSIVE); diff --git a/pgrx/src/rel.rs b/pgrx/src/rel.rs index 8206e2e0c6..aedbe2b809 100644 --- a/pgrx/src/rel.rs +++ b/pgrx/src/rel.rs @@ -235,7 +235,7 @@ impl PgRelation { /// // assert that the tuple descriptor has 12 attributes /// assert_eq!(tupdesc.len(), 12); /// ``` - pub fn tuple_desc(&self) -> PgTupleDesc { + pub fn tuple_desc(&self) -> PgTupleDesc<'_> { PgTupleDesc::from_relation(self) } diff --git a/pgrx/src/spi/cursor.rs b/pgrx/src/spi/cursor.rs index 8aaa547577..5efb8cbe36 100644 --- a/pgrx/src/spi/cursor.rs +++ b/pgrx/src/spi/cursor.rs @@ -72,7 +72,7 @@ impl SpiCursor<'_> { /// Fetch up to `count` rows from the cursor, moving forward /// /// If `fetch` runs off the end of the available rows, an empty [`SpiTupleTable`] is returned. - pub fn fetch(&mut self, count: libc::c_long) -> SpiResult { + pub fn fetch(&mut self, count: libc::c_long) -> SpiResult> { // SAFETY: no concurrent access unsafe { pg_sys::SPI_tuptable = std::ptr::null_mut(); diff --git a/pgrx/src/tupdesc.rs b/pgrx/src/tupdesc.rs index 226b747302..db4de853ab 100644 --- a/pgrx/src/tupdesc.rs +++ b/pgrx/src/tupdesc.rs @@ -142,7 +142,7 @@ impl<'a> PgTupleDesc<'a> { } /// wrap the `pg_sys::TupleDesc` contained by the specified `PgRelation` - pub fn from_relation(parent: &PgRelation) -> PgTupleDesc { + pub fn from_relation(parent: &PgRelation) -> PgTupleDesc<'_> { PgTupleDesc { // SAFETY: `parent` is a Rust reference, and as such its rd_att attribute will be property initialized tupdesc: Some(unsafe { PgBox::from_pg(parent.rd_att) }), @@ -232,7 +232,7 @@ impl<'a> PgTupleDesc<'a> { } /// Iterate over our attributes - pub fn iter(&self) -> TupleDescIterator { + pub fn iter(&self) -> TupleDescIterator<'_> { TupleDescIterator { tupdesc: self, curr: 0 } }