From ed1fbd47b93d804bc2e7975c126892f3e7a0767e Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:09:15 -0700 Subject: [PATCH 1/9] Move lint control to toml --- cargo-pgrx/Cargo.toml | 3 +++ cargo-pgrx/src/main.rs | 3 --- pgrx-sql-entity-graph/Cargo.toml | 2 ++ pgrx-sql-entity-graph/src/lib.rs | 2 -- pgrx/Cargo.toml | 8 ++++++++ pgrx/src/lib.rs | 8 -------- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cargo-pgrx/Cargo.toml b/cargo-pgrx/Cargo.toml index 92ddb68aa..9b8fceac7 100644 --- a/cargo-pgrx/Cargo.toml +++ b/cargo-pgrx/Cargo.toml @@ -70,3 +70,6 @@ rustls = [ "ureq/tls", "ureq/native-certs" # induces rustls to use the OS-level root of trust ] + +[lints.clippy] +or-fun-call = "allow" # kinda sus lint imo diff --git a/cargo-pgrx/src/main.rs b/cargo-pgrx/src/main.rs index 338f3df14..81b22542c 100644 --- a/cargo-pgrx/src/main.rs +++ b/cargo-pgrx/src/main.rs @@ -7,9 +7,6 @@ //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. -#![deny(clippy::perf)] // our compile times are awful -#![allow(clippy::or_fun_call)] // often false positives - mod command; mod manifest; mod metadata; diff --git a/pgrx-sql-entity-graph/Cargo.toml b/pgrx-sql-entity-graph/Cargo.toml index d73b1ebbe..10e6dfe59 100644 --- a/pgrx-sql-entity-graph/Cargo.toml +++ b/pgrx-sql-entity-graph/Cargo.toml @@ -42,3 +42,5 @@ syntect = { version = "5.1.0", default-features = false, features = ["default-fa [lints.clippy] assigning-clones = "allow" # wrong diagnosis and wrong suggestions +redundant-pattern-matching = "allow" +too-many-arguments = "allow" # I argue with myself all the time diff --git a/pgrx-sql-entity-graph/src/lib.rs b/pgrx-sql-entity-graph/src/lib.rs index c18eec922..fcb1f1bb5 100644 --- a/pgrx-sql-entity-graph/src/lib.rs +++ b/pgrx-sql-entity-graph/src/lib.rs @@ -15,8 +15,6 @@ Rust to SQL mapping support. to the `pgrx` framework and very subject to change between versions. While you may use this, please do it with caution. */ -#![allow(clippy::too_many_arguments)] -#![allow(clippy::redundant_pattern_matching)] pub use aggregate::entity::{AggregateTypeEntity, PgAggregateEntity}; pub use aggregate::{ AggregateType, AggregateTypeList, FinalizeModify, ParallelOption, PgAggregate, diff --git a/pgrx/Cargo.toml b/pgrx/Cargo.toml index f94420541..fb1ed6603 100644 --- a/pgrx/Cargo.toml +++ b/pgrx/Cargo.toml @@ -66,3 +66,11 @@ seahash = "4.1.0" # derive(PostgresHash) serde.workspace = true # impls on pub types serde_cbor = "0.11.2" # derive(PostgresType) serde_json.workspace = true # everything JSON + +[lints] +clippy.cast_ptr_alignment = "allow" +clippy.len_without_is_empty = "allow" +clippy.missing_safety_doc = "allow" +clippy.too_many_arguments = "allow" +clippy.type_complexity = "allow" +clippy.unnecessary_cast = "allow" diff --git a/pgrx/src/lib.rs b/pgrx/src/lib.rs index 2b0907083..d119697bb 100644 --- a/pgrx/src/lib.rs +++ b/pgrx/src/lib.rs @@ -21,14 +21,6 @@ //! } //! //! ``` -#![allow( - clippy::cast_ptr_alignment, - clippy::len_without_is_empty, - clippy::missing_safety_doc, - clippy::too_many_arguments, - clippy::type_complexity, - clippy::unnecessary_cast -)] #![cfg_attr(feature = "nightly", feature(allocator_api))] #[macro_use] From 5ebbe0dc9eb4b348511352e4d7318a2b32993a2e Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:11:18 -0700 Subject: [PATCH 2/9] remove needless lifetimes --- pgrx-sql-entity-graph/src/finfo.rs | 12 +----------- pgrx-tests/Cargo.toml | 3 +++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/pgrx-sql-entity-graph/src/finfo.rs b/pgrx-sql-entity-graph/src/finfo.rs index 812d59154..67ec69842 100644 --- a/pgrx-sql-entity-graph/src/finfo.rs +++ b/pgrx-sql-entity-graph/src/finfo.rs @@ -26,21 +26,11 @@ pub fn finfo_v1_extern_c( ) -> syn::Result { let original_name = &original.sig.ident; let wrapper_symbol = format_ident!("{}_wrapper", original_name); - let lifetimes = &original.sig.generics; - // the wrapper function declaration may contain lifetimes that are not used, since - // our input type is FunctionCallInfo and our return type is Datum - let unused_lifetimes = match lifetimes.lifetimes().next() { - Some(_) => quote! { - #[allow(unused_lifetimes, clippy::extra_unused_lifetimes)] - }, - None => quote! {}, - }; let tokens = quote_spanned! { original.sig.span() => #[no_mangle] #[doc(hidden)] - #unused_lifetimes - pub unsafe extern "C" fn #wrapper_symbol #lifetimes(#fcinfo: ::pgrx::pg_sys::FunctionCallInfo) -> ::pgrx::pg_sys::Datum { + pub unsafe extern "C" fn #wrapper_symbol(#fcinfo: ::pgrx::pg_sys::FunctionCallInfo) -> ::pgrx::pg_sys::Datum { #contents } }; diff --git a/pgrx-tests/Cargo.toml b/pgrx-tests/Cargo.toml index c77fe3850..d3aef8474 100644 --- a/pgrx-tests/Cargo.toml +++ b/pgrx-tests/Cargo.toml @@ -76,3 +76,6 @@ version = "=0.12.0-alpha.1" [dev-dependencies] eyre.workspace = true # testing functions that return `eyre::Result` trybuild = "1" + +[lints] +unused-lifetimes = "deny" From 88e02edead237fbb03f47e783afe0a1ce13eb678 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:14:40 -0700 Subject: [PATCH 3/9] Deny unused lifetimes in tests --- pgrx-macros/src/rewriter.rs | 9 --------- pgrx-tests/Cargo.toml | 2 +- pgrx-tests/src/tests/pg_guard_tests.rs | 1 + 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pgrx-macros/src/rewriter.rs b/pgrx-macros/src/rewriter.rs index 49561c883..5af2bf88a 100644 --- a/pgrx-macros/src/rewriter.rs +++ b/pgrx-macros/src/rewriter.rs @@ -58,14 +58,6 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result quote! { - #[allow(unused_lifetimes, clippy::extra_unused_lifetimes)] - }, - None => quote! {}, - }; - let arg_list = build_arg_list(&sig, false)?; let func_name = func.sig.ident.clone(); @@ -103,7 +95,6 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result bool { // and [no_mangle] #[pg_guard] #[no_mangle] +#[allow(unused_lifetimes)] extern "C" fn extern_func_impl_2<'a>() -> bool { true } From cbe4a1e437e28fce5366d68f6c927b7f4f7fc29d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:17:37 -0700 Subject: [PATCH 4/9] Deny used-underscore-parameter --- pgrx-tests/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pgrx-tests/Cargo.toml b/pgrx-tests/Cargo.toml index bdfea5558..8dea456d4 100644 --- a/pgrx-tests/Cargo.toml +++ b/pgrx-tests/Cargo.toml @@ -79,3 +79,4 @@ trybuild = "1" [lints] rust.unused-lifetimes = "deny" +clippy.used-underscore-parameter = "deny" From 33ca900b2e715c69264b09dc9deb0b4246a3deba Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:17:37 -0700 Subject: [PATCH 5/9] Deny used-underscore-binding --- pgrx-tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgrx-tests/Cargo.toml b/pgrx-tests/Cargo.toml index 8dea456d4..405723d68 100644 --- a/pgrx-tests/Cargo.toml +++ b/pgrx-tests/Cargo.toml @@ -79,4 +79,4 @@ trybuild = "1" [lints] rust.unused-lifetimes = "deny" -clippy.used-underscore-parameter = "deny" +clippy.used-underscore-binding = "deny" From babc17534e9cf1007a1321f9a57469ad8b068941 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:23:08 -0700 Subject: [PATCH 6/9] Lift one last set of lints to config --- pgrx-pg-sys/Cargo.toml | 11 +++++++++++ pgrx-pg-sys/src/lib.rs | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pgrx-pg-sys/Cargo.toml b/pgrx-pg-sys/Cargo.toml index c7e72b248..deb00db21 100644 --- a/pgrx-pg-sys/Cargo.toml +++ b/pgrx-pg-sys/Cargo.toml @@ -63,3 +63,14 @@ bindgen = { version = "0.69", default-features = false, features = ["runtime"] } clang-sys = { version = "1", features = ["clang_6_0", "runtime"] } quote = "1.0.33" shlex = "1.3" # shell lexing, also used by many of our deps + +[lints] +# we allow improper_ctypes just to eliminate these warnings: +# = note: `#[warn(improper_ctypes)]` on by default +# = note: 128-bit integers don't currently have a known stable ABI +rust.non_camel_case_types = "allow" +rust.non_snake_case = "allow" +rust.dead_code = "allow" +rust.non_upper_case_globals = "allow" +rust.improper_ctypes = "allow" +clippy.unneeded_field_pattern = "allow" diff --git a/pgrx-pg-sys/src/lib.rs b/pgrx-pg-sys/src/lib.rs index c66b809a3..56e040bf5 100644 --- a/pgrx-pg-sys/src/lib.rs +++ b/pgrx-pg-sys/src/lib.rs @@ -7,17 +7,6 @@ //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. -// -// we allow improper_ctypes just to eliminate these warnings: -// = note: `#[warn(improper_ctypes)]` on by default -// = note: 128-bit integers don't currently have a known stable ABI -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(dead_code)] -#![allow(non_upper_case_globals)] -#![allow(improper_ctypes)] -#![allow(clippy::unneeded_field_pattern)] - #[cfg( // no features at all will cause problems not(any(feature = "pg12", feature = "pg13", feature = "pg14", feature = "pg15", feature = "pg16")), From 7bee2c647b078d4ab941c5c9c6b44fc43d126df4 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 20:49:57 -0700 Subject: [PATCH 7/9] Dont need mutability --- pgrx-macros/src/rewriter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgrx-macros/src/rewriter.rs b/pgrx-macros/src/rewriter.rs index 5af2bf88a..a25b65b2e 100644 --- a/pgrx-macros/src/rewriter.rs +++ b/pgrx-macros/src/rewriter.rs @@ -36,7 +36,7 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result Date: Fri, 28 Jun 2024 20:57:13 -0700 Subject: [PATCH 8/9] Remove an allowed case --- pgrx-sql-entity-graph/Cargo.toml | 1 - pgrx-sql-entity-graph/src/pgrx_attribute.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pgrx-sql-entity-graph/Cargo.toml b/pgrx-sql-entity-graph/Cargo.toml index 10e6dfe59..d2eeb9fd9 100644 --- a/pgrx-sql-entity-graph/Cargo.toml +++ b/pgrx-sql-entity-graph/Cargo.toml @@ -42,5 +42,4 @@ syntect = { version = "5.1.0", default-features = false, features = ["default-fa [lints.clippy] assigning-clones = "allow" # wrong diagnosis and wrong suggestions -redundant-pattern-matching = "allow" too-many-arguments = "allow" # I argue with myself all the time diff --git a/pgrx-sql-entity-graph/src/pgrx_attribute.rs b/pgrx-sql-entity-graph/src/pgrx_attribute.rs index f838fa08e..5ffd2d6a7 100644 --- a/pgrx-sql-entity-graph/src/pgrx_attribute.rs +++ b/pgrx-sql-entity-graph/src/pgrx_attribute.rs @@ -65,7 +65,7 @@ impl Parse for PgrxArg { #[track_caller] fn parse(input: ParseStream<'_>) -> syn::Result { let path = input.parse::()?; - if let Ok(_) = input.parse::() { + if input.parse::().is_ok() { Ok(Self::NameValue(NameValueArg { path, value: input.parse()? })) } else { Err(input.error("unsupported argument to #[pgrx] in this context")) From bcdd0efdc51084c791f157796fd41eacace353cc Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 28 Jun 2024 21:01:15 -0700 Subject: [PATCH 9/9] Another allowed case redundant --- pgrx-pg-sys/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pgrx-pg-sys/Cargo.toml b/pgrx-pg-sys/Cargo.toml index deb00db21..e2bd098d9 100644 --- a/pgrx-pg-sys/Cargo.toml +++ b/pgrx-pg-sys/Cargo.toml @@ -73,4 +73,3 @@ rust.non_snake_case = "allow" rust.dead_code = "allow" rust.non_upper_case_globals = "allow" rust.improper_ctypes = "allow" -clippy.unneeded_field_pattern = "allow"