Skip to content

Commit ea1d036

Browse files
committed
Consolidate clippy configuration
Move all clippy configurations to one central place, except for the expected tests - they seem to require their own handling for now due to a Cargo limitation. Also, fixed a lot of `unused_qualifications` lints.
1 parent c4440b3 commit ea1d036

File tree

24 files changed

+95
-75
lines changed

24 files changed

+95
-75
lines changed

Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ shlex = "1"
2020
syn = "2.0"
2121
proc-macro2 = { version = "1", default-features = false }
2222

23+
[workspace.lints.rust]
24+
deprecated = "allow"
25+
invalid-value = "allow"
26+
non-snake-case = "allow"
27+
unexpected-cfgs = "allow"
28+
unsupported_calling_conventions = "allow"
29+
unused_qualifications = "warn"
30+
31+
[workspace.lints.clippy]
32+
disallowed-names = "allow"
33+
manual-c-str-literals = "allow"
34+
missing-safety-doc = "allow"
35+
op-ref = "allow"
36+
ptr-offset-with-cast = "allow"
37+
too-many-arguments = "allow"
38+
transmute-int-to-bool = "allow"
39+
unnecessary-cast = "allow"
40+
useless-transmute = "allow"
41+
2342
# Config for 'cargo dist'
2443
[workspace.metadata.dist]
2544
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)

bindgen-cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lints.workspace = true
2+
13
[package]
24
authors = [
35
"The rust-bindgen project contributors",

bindgen-integration/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lints.workspace = true
2+
13
[package]
24
name = "bindgen-integration"
35
description = "A package to test various bindgen features"

bindgen-integration/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn setup_macro_test() {
183183
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
184184
let out_rust_file = out_path.join("test.rs");
185185
let out_rust_file_relative = out_rust_file
186-
.strip_prefix(std::env::current_dir().unwrap().parent().unwrap())
186+
.strip_prefix(env::current_dir().unwrap().parent().unwrap())
187187
.unwrap();
188188
let out_dep_file = out_path.join("test.d");
189189

bindgen-tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lints.workspace = true
2+
13
[package]
24
name = "bindgen-tests"
35
edition = "2021"

bindgen-tests/tests/expectations/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ block = "0.1"
1515
libloading = "0.7"
1616
objc = "0.2"
1717

18+
# Both of these sections need to be copied here from the workspace because
19+
# Cargo currently does not allow overriding workspace settings in a member
1820
[lints.rust]
1921
### FIXME: these might need to be fixed,
2022
### esp the calling convention, because it is a hard error now
@@ -23,6 +25,7 @@ objc = "0.2"
2325
# unsupported_calling_conventions = "allow"
2426
non-snake-case = "allow"
2527
unexpected-cfgs = "allow"
28+
unused_qualifications = "allow" # Different from the workspace
2629

2730
[lints.clippy]
2831
disallowed-names = "allow"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#![allow(dead_code)]
22
#![allow(non_camel_case_types)]
33
#![allow(non_upper_case_globals)]
4+
#![allow(unused_qualifications)]

bindgen-tests/tests/quickchecking/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lints.workspace = true
2+
13
[package]
24
name = "quickchecking"
35
description = "Bindgen property tests with quickcheck. Generate random valid C code and pass it to the csmith/predicate.py script"

bindgen-tests/tests/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ include!(concat!(env!("OUT_DIR"), "/tests.rs"));
371371
#[test]
372372
#[cfg_attr(target_os = "windows", ignore)]
373373
fn test_clang_env_args() {
374-
std::env::set_var(
374+
env::set_var(
375375
"BINDGEN_EXTRA_CLANG_ARGS",
376376
"-D_ENV_ONE=1 -D_ENV_TWO=\"2 -DNOT_THREE=1\"",
377377
);
@@ -653,8 +653,8 @@ fn emit_depfile() {
653653
builder.into_builder(check_roundtrip).unwrap();
654654
let _bindings = builder.generate().unwrap();
655655

656-
let observed = std::fs::read_to_string(observed_depfile).unwrap();
657-
let expected = std::fs::read_to_string(expected_depfile).unwrap();
656+
let observed = fs::read_to_string(observed_depfile).unwrap();
657+
let expected = fs::read_to_string(expected_depfile).unwrap();
658658
assert_eq!(observed.trim(), expected.trim());
659659
}
660660

@@ -694,7 +694,7 @@ fn dump_preprocessed_input() {
694694
);
695695
}
696696

697-
fn build_flags_output_helper(builder: &bindgen::Builder) {
697+
fn build_flags_output_helper(builder: &Builder) {
698698
let mut command_line_flags = builder.command_line_flags();
699699
command_line_flags.insert(0, "bindgen".to_string());
700700

@@ -712,7 +712,7 @@ fn build_flags_output_helper(builder: &bindgen::Builder) {
712712

713713
#[test]
714714
fn commandline_multiple_headers() {
715-
let bindings = bindgen::Builder::default()
715+
let bindings = Builder::default()
716716
.header("tests/headers/char.h")
717717
.header("tests/headers/func_ptr.h")
718718
.header("tests/headers/16-byte-alignment.h");

bindgen/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lints.workspace = true
2+
13
[package]
24
authors = [
35
"Jyun-Yan You <[email protected]>",

0 commit comments

Comments
 (0)