Skip to content

Commit ccfab12

Browse files
Deny lints pre-ArgAbi codegen used to trigger (pgcentralfoundation#1744)
Lifts instances of crate-wide lint control into Cargo.toml and denies some of them for pgrx-tests so that pgrx's macro expansions no longer emit needless `allow`s in quite as many places. This also trims away a few now-needless allowances.
1 parent e77bbf9 commit ccfab12

13 files changed

Lines changed: 30 additions & 46 deletions

File tree

cargo-pgrx/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ rustls = [
7070
"ureq/tls",
7171
"ureq/native-certs" # induces rustls to use the OS-level root of trust
7272
]
73+
74+
[lints.clippy]
75+
or-fun-call = "allow" # kinda sus lint imo

cargo-pgrx/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
//LICENSE All rights reserved.
88
//LICENSE
99
//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file.
10-
#![deny(clippy::perf)] // our compile times are awful
11-
#![allow(clippy::or_fun_call)] // often false positives
12-
1310
mod command;
1411
mod manifest;
1512
mod metadata;

pgrx-macros/src/rewriter.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result<proc_macro2::Tok
3636
let input_func_name = func.sig.ident.to_string();
3737
let sig = func.sig.clone();
3838
let vis = func.vis.clone();
39-
let mut attrs = mem::take(&mut func.attrs);
39+
let attrs = mem::take(&mut func.attrs);
4040
let generics = func.sig.generics.clone();
4141

4242
if attrs.iter().any(|attr| attr.path().is_ident("no_mangle"))
@@ -58,14 +58,6 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result<proc_macro2::Tok
5858

5959
func.sig.ident = format_ident!("{}_inner", func.sig.ident);
6060

61-
// the wrapper_inner function declaration may contain lifetimes that are not used, since our input type is `FunctionCallInfo` mainly and return type is `Datum`
62-
let unused_lifetimes = match generics.lifetimes().next() {
63-
Some(_) => quote! {
64-
#[allow(unused_lifetimes, clippy::extra_unused_lifetimes)]
65-
},
66-
None => quote! {},
67-
};
68-
6961
let arg_list = build_arg_list(&sig, false)?;
7062
let func_name = func.sig.ident.clone();
7163

@@ -103,7 +95,6 @@ pub fn item_fn_without_rewrite(mut func: ItemFn) -> syn::Result<proc_macro2::Tok
10395
#(#attrs)*
10496
#vis #sig {
10597
#[allow(non_snake_case)]
106-
#unused_lifetimes
10798
#func
10899

109100
#[allow(unused_unsafe)]

pgrx-pg-sys/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ bindgen = { version = "0.69", default-features = false, features = ["runtime"] }
6363
clang-sys = { version = "1", features = ["clang_6_0", "runtime"] }
6464
quote = "1.0.33"
6565
shlex = "1.3" # shell lexing, also used by many of our deps
66+
67+
[lints]
68+
# we allow improper_ctypes just to eliminate these warnings:
69+
# = note: `#[warn(improper_ctypes)]` on by default
70+
# = note: 128-bit integers don't currently have a known stable ABI
71+
rust.non_camel_case_types = "allow"
72+
rust.non_snake_case = "allow"
73+
rust.dead_code = "allow"
74+
rust.non_upper_case_globals = "allow"
75+
rust.improper_ctypes = "allow"

pgrx-pg-sys/src/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@
77
//LICENSE All rights reserved.
88
//LICENSE
99
//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file.
10-
//
11-
// we allow improper_ctypes just to eliminate these warnings:
12-
// = note: `#[warn(improper_ctypes)]` on by default
13-
// = note: 128-bit integers don't currently have a known stable ABI
14-
#![allow(non_camel_case_types)]
15-
#![allow(non_snake_case)]
16-
#![allow(dead_code)]
17-
#![allow(non_upper_case_globals)]
18-
#![allow(improper_ctypes)]
19-
#![allow(clippy::unneeded_field_pattern)]
20-
2110
#[cfg(
2211
// no features at all will cause problems
2312
not(any(feature = "pg12", feature = "pg13", feature = "pg14", feature = "pg15", feature = "pg16")),

pgrx-sql-entity-graph/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ syntect = { version = "5.1.0", default-features = false, features = ["default-fa
4242

4343
[lints.clippy]
4444
assigning-clones = "allow" # wrong diagnosis and wrong suggestions
45+
too-many-arguments = "allow" # I argue with myself all the time

pgrx-sql-entity-graph/src/finfo.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,11 @@ pub fn finfo_v1_extern_c(
2626
) -> syn::Result<ItemFn> {
2727
let original_name = &original.sig.ident;
2828
let wrapper_symbol = format_ident!("{}_wrapper", original_name);
29-
let lifetimes = &original.sig.generics;
30-
// the wrapper function declaration may contain lifetimes that are not used, since
31-
// our input type is FunctionCallInfo and our return type is Datum
32-
let unused_lifetimes = match lifetimes.lifetimes().next() {
33-
Some(_) => quote! {
34-
#[allow(unused_lifetimes, clippy::extra_unused_lifetimes)]
35-
},
36-
None => quote! {},
37-
};
3829

3930
let tokens = quote_spanned! { original.sig.span() =>
4031
#[no_mangle]
4132
#[doc(hidden)]
42-
#unused_lifetimes
43-
pub unsafe extern "C" fn #wrapper_symbol #lifetimes(#fcinfo: ::pgrx::pg_sys::FunctionCallInfo) -> ::pgrx::pg_sys::Datum {
33+
pub unsafe extern "C" fn #wrapper_symbol(#fcinfo: ::pgrx::pg_sys::FunctionCallInfo) -> ::pgrx::pg_sys::Datum {
4434
#contents
4535
}
4636
};

pgrx-sql-entity-graph/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Rust to SQL mapping support.
1515
to the `pgrx` framework and very subject to change between versions. While you may use this, please do it with caution.
1616
1717
*/
18-
#![allow(clippy::too_many_arguments)]
19-
#![allow(clippy::redundant_pattern_matching)]
2018
pub use aggregate::entity::{AggregateTypeEntity, PgAggregateEntity};
2119
pub use aggregate::{
2220
AggregateType, AggregateTypeList, FinalizeModify, ParallelOption, PgAggregate,

pgrx-sql-entity-graph/src/pgrx_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Parse for PgrxArg {
6565
#[track_caller]
6666
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
6767
let path = input.parse::<syn::Path>()?;
68-
if let Ok(_) = input.parse::<Token![=]>() {
68+
if input.parse::<Token![=]>().is_ok() {
6969
Ok(Self::NameValue(NameValueArg { path, value: input.parse()? }))
7070
} else {
7171
Err(input.error("unsupported argument to #[pgrx] in this context"))

pgrx-tests/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ version = "=0.12.0-alpha.1"
7676
[dev-dependencies]
7777
eyre.workspace = true # testing functions that return `eyre::Result`
7878
trybuild = "1"
79+
80+
[lints]
81+
rust.unused-lifetimes = "deny"
82+
clippy.used-underscore-binding = "deny"

0 commit comments

Comments
 (0)