From 9d35128840908020416d42e504c6fe256a1d82db Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 22 Nov 2023 15:10:27 +0000 Subject: [PATCH] Use Clippy lint table over Cargo config (#490) Closes https://github.com/astral-sh/puffin/issues/482. --- .cargo/config.toml | 33 ------------------------- Cargo.toml | 32 +++++++++++++++++++++++- crates/bench/Cargo.toml | 3 +++ crates/distribution-filename/Cargo.toml | 3 +++ crates/distribution-types/Cargo.toml | 3 +++ crates/gourgeist/Cargo.toml | 3 +++ crates/install-wheel-rs/Cargo.toml | 3 +++ crates/platform-host/Cargo.toml | 3 +++ crates/platform-host/src/linux.rs | 8 +++--- crates/platform-tags/Cargo.toml | 3 +++ crates/puffin-build/Cargo.toml | 3 +++ crates/puffin-build/src/lib.rs | 4 +-- crates/puffin-cache/Cargo.toml | 3 +++ crates/puffin-cli/Cargo.toml | 3 +++ crates/puffin-dev/Cargo.toml | 3 +++ crates/puffin-dispatch/Cargo.toml | 3 +++ crates/puffin-distribution/Cargo.toml | 3 +++ crates/puffin-git/Cargo.toml | 3 +++ crates/puffin-installer/Cargo.toml | 3 +++ crates/puffin-interpreter/Cargo.toml | 3 +++ crates/puffin-macros/Cargo.toml | 3 +++ crates/puffin-resolver/Cargo.toml | 3 +++ crates/puffin-traits/Cargo.toml | 3 +++ crates/puffin-workspace/Cargo.toml | 3 +++ crates/pypi-types/Cargo.toml | 3 +++ crates/requirements-txt/Cargo.toml | 3 +++ crates/requirements-txt/src/lib.rs | 4 +-- rust-toolchain.toml | 2 +- 28 files changed, 106 insertions(+), 43 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index ca8c7f355..000000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,33 +0,0 @@ -[target.'cfg(all())'] -rustflags = [ - # CLIPPY LINT SETTINGS - # This is a workaround to configure lints for the entire workspace, pending the ability to configure this via TOML. - # See: `https://github.com/rust-lang/cargo/issues/5034` - # `https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395` - "-Dunsafe_code", - "-Wclippy::pedantic", - # Allowed pedantic lints - "-Wclippy::char_lit_as_u8", - "-Aclippy::collapsible_else_if", - "-Aclippy::collapsible_if", - "-Aclippy::implicit_hasher", - "-Aclippy::match_same_arms", - "-Aclippy::missing_errors_doc", - "-Aclippy::missing_panics_doc", - "-Aclippy::module_name_repetitions", - "-Aclippy::must_use_candidate", - "-Aclippy::similar_names", - "-Aclippy::too_many_lines", - # Disallowed restriction lints - "-Wclippy::print_stdout", - "-Wclippy::print_stderr", - "-Wclippy::dbg_macro", - "-Wclippy::empty_drop", - "-Wclippy::empty_structs_with_brackets", - "-Wclippy::exit", - "-Wclippy::get_unwrap", - "-Wclippy::rc_buffer", - "-Wclippy::rc_mutex", - "-Wclippy::rest_pat_in_fully_bound_structs", - "-Wunreachable_pub" -] diff --git a/Cargo.toml b/Cargo.toml index ce9a3a5a2..a645617ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ resolver = "2" [workspace.package] edition = "2021" -rust-version = "1.72" +rust-version = "1.74" homepage = "https://astral.sh" documentation = "https://astral.sh" repository = "https://github.com/astral-sh/puffin" @@ -93,6 +93,36 @@ zip = { version = "0.6.6", default-features = false, features = ["deflate"] } # For pyproject-toml pep508_rs = { path = "crates/pep508-rs" } +[workspace.lints.rust] +unsafe_code = "warn" +unreachable_pub = "warn" + +[workspace.lints.clippy] +pedantic = { level = "warn", priority = -2 } +# Allowed pedantic lints +char_lit_as_u8 = "allow" +collapsible_else_if = "allow" +collapsible_if = "allow" +implicit_hasher = "allow" +match_same_arms = "allow" +missing_errors_doc = "allow" +missing_panics_doc = "allow" +module_name_repetitions = "allow" +must_use_candidate = "allow" +similar_names = "allow" +too_many_lines = "allow" +# Disallowed restriction lints +print_stdout = "warn" +print_stderr = "warn" +dbg_macro = "warn" +empty_drop = "warn" +empty_structs_with_brackets = "warn" +exit = "warn" +get_unwrap = "warn" +rc_buffer = "warn" +rc_mutex = "warn" +rest_pat_in_fully_bound_structs = "warn" + [profile.profiling] inherits = "release" debug = true diff --git a/crates/bench/Cargo.toml b/crates/bench/Cargo.toml index 6e3937554..f0cb8364e 100644 --- a/crates/bench/Cargo.toml +++ b/crates/bench/Cargo.toml @@ -11,6 +11,9 @@ documentation = { workspace = true } repository = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [lib] bench = false diff --git a/crates/distribution-filename/Cargo.toml b/crates/distribution-filename/Cargo.toml index 214bf7458..74d97f099 100644 --- a/crates/distribution-filename/Cargo.toml +++ b/crates/distribution-filename/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep440_rs = { path = "../pep440-rs" } platform-tags = { path = "../platform-tags" } diff --git a/crates/distribution-types/Cargo.toml b/crates/distribution-types/Cargo.toml index 59595f631..7d3be2d46 100644 --- a/crates/distribution-types/Cargo.toml +++ b/crates/distribution-types/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } pep440_rs = { path = "../pep440-rs" } diff --git a/crates/gourgeist/Cargo.toml b/crates/gourgeist/Cargo.toml index b51d10925..be00a8166 100644 --- a/crates/gourgeist/Cargo.toml +++ b/crates/gourgeist/Cargo.toml @@ -13,6 +13,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] platform-host = { path = "../platform-host" } puffin-interpreter = { path = "../puffin-interpreter" } diff --git a/crates/install-wheel-rs/Cargo.toml b/crates/install-wheel-rs/Cargo.toml index 18a4bd724..5e4f0b174 100644 --- a/crates/install-wheel-rs/Cargo.toml +++ b/crates/install-wheel-rs/Cargo.toml @@ -13,6 +13,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [lib] name = "install_wheel_rs" diff --git a/crates/platform-host/Cargo.toml b/crates/platform-host/Cargo.toml index eec8ed886..2f5480f82 100644 --- a/crates/platform-host/Cargo.toml +++ b/crates/platform-host/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] fs-err = { workspace = true } goblin = { workspace = true } diff --git a/crates/platform-host/src/linux.rs b/crates/platform-host/src/linux.rs index f79cccec5..9b9c208d7 100644 --- a/crates/platform-host/src/linux.rs +++ b/crates/platform-host/src/linux.rs @@ -139,21 +139,21 @@ mod tests { #[test] fn parse_ldd_output() { let ver_str = ldd_output_to_version_str( - r#"ldd (GNU libc) 2.12 + r"ldd (GNU libc) 2.12 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Written by Roland McGrath and Ulrich Drepper."#, +Written by Roland McGrath and Ulrich Drepper.", ) .unwrap(); assert_eq!(ver_str, "2.12"); let ver_str = ldd_output_to_version_str( - r#"ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31 + r"ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - Written by Roland McGrath and Ulrich Drepper."#, + Written by Roland McGrath and Ulrich Drepper.", ) .unwrap(); assert_eq!(ver_str, "2.31"); diff --git a/crates/platform-tags/Cargo.toml b/crates/platform-tags/Cargo.toml index 4a32ed89f..28cfd899d 100644 --- a/crates/platform-tags/Cargo.toml +++ b/crates/platform-tags/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] platform-host = { path = "../platform-host" } diff --git a/crates/puffin-build/Cargo.toml b/crates/puffin-build/Cargo.toml index 61b276a44..b30ba6c94 100644 --- a/crates/puffin-build/Cargo.toml +++ b/crates/puffin-build/Cargo.toml @@ -10,6 +10,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] gourgeist = { path = "../gourgeist" } pep508_rs = { path = "../pep508-rs" } diff --git a/crates/puffin-build/src/lib.rs b/crates/puffin-build/src/lib.rs index 4be971510..73eb52599 100644 --- a/crates/puffin-build/src/lib.rs +++ b/crates/puffin-build/src/lib.rs @@ -646,13 +646,13 @@ mod test { fn missing_header() { let output = Output { status: ExitStatus::default(), // This is wrong but `from_raw` is platform gated - stdout: indoc!(r#" + stdout: indoc!(r" running bdist_wheel running build [...] creating build/temp.linux-x86_64-cpython-39/pygraphviz gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DOPENSSL_NO_SSL3 -fPIC -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/tmp/.tmpy6vVes/.venv/include -I/home/konsti/.pyenv/versions/3.9.18/include/python3.9 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-cpython-39/pygraphviz/graphviz_wrap.o - "# + " ).as_bytes().to_vec(), stderr: indoc!(r#" warning: no files found matching '*.png' under directory 'doc' diff --git a/crates/puffin-cache/Cargo.toml b/crates/puffin-cache/Cargo.toml index ff511b154..9cfb89ab5 100644 --- a/crates/puffin-cache/Cargo.toml +++ b/crates/puffin-cache/Cargo.toml @@ -10,6 +10,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } pypi-types = { path = "../pypi-types" } diff --git a/crates/puffin-cli/Cargo.toml b/crates/puffin-cli/Cargo.toml index 1eeb88b96..a837556fe 100644 --- a/crates/puffin-cli/Cargo.toml +++ b/crates/puffin-cli/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [[bin]] name = "puffin" path = "src/main.rs" diff --git a/crates/puffin-dev/Cargo.toml b/crates/puffin-dev/Cargo.toml index 6a8f852cb..70255ec46 100644 --- a/crates/puffin-dev/Cargo.toml +++ b/crates/puffin-dev/Cargo.toml @@ -10,6 +10,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } gourgeist = { path = "../gourgeist" } diff --git a/crates/puffin-dispatch/Cargo.toml b/crates/puffin-dispatch/Cargo.toml index b1806121c..74111be12 100644 --- a/crates/puffin-dispatch/Cargo.toml +++ b/crates/puffin-dispatch/Cargo.toml @@ -10,6 +10,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-types = { path = "../distribution-types" } gourgeist = { path = "../gourgeist" } diff --git a/crates/puffin-distribution/Cargo.toml b/crates/puffin-distribution/Cargo.toml index 96b3437d8..96fb8f600 100644 --- a/crates/puffin-distribution/Cargo.toml +++ b/crates/puffin-distribution/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } distribution-types = { path = "../distribution-types" } diff --git a/crates/puffin-git/Cargo.toml b/crates/puffin-git/Cargo.toml index 277caf324..75a175b3b 100644 --- a/crates/puffin-git/Cargo.toml +++ b/crates/puffin-git/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] puffin-cache = { path = "../puffin-cache" } diff --git a/crates/puffin-installer/Cargo.toml b/crates/puffin-installer/Cargo.toml index 8f61fa963..a43b731d1 100644 --- a/crates/puffin-installer/Cargo.toml +++ b/crates/puffin-installer/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } install-wheel-rs = { path = "../install-wheel-rs", default-features = false } diff --git a/crates/puffin-interpreter/Cargo.toml b/crates/puffin-interpreter/Cargo.toml index 049052f89..fe45ea371 100644 --- a/crates/puffin-interpreter/Cargo.toml +++ b/crates/puffin-interpreter/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep440_rs = { path = "../pep440-rs" } pep508_rs = { path = "../pep508-rs", features = ["serde"] } diff --git a/crates/puffin-macros/Cargo.toml b/crates/puffin-macros/Cargo.toml index 781d063fe..e01430ca2 100644 --- a/crates/puffin-macros/Cargo.toml +++ b/crates/puffin-macros/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] colored = { workspace = true } fxhash = { workspace = true } diff --git a/crates/puffin-resolver/Cargo.toml b/crates/puffin-resolver/Cargo.toml index 1a9039deb..011e58470 100644 --- a/crates/puffin-resolver/Cargo.toml +++ b/crates/puffin-resolver/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] distribution-filename = { path = "../distribution-filename" } install-wheel-rs = { path = "../install-wheel-rs" } diff --git a/crates/puffin-traits/Cargo.toml b/crates/puffin-traits/Cargo.toml index 69111ee10..d9b2174d6 100644 --- a/crates/puffin-traits/Cargo.toml +++ b/crates/puffin-traits/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep508_rs = { path = "../pep508-rs" } puffin-interpreter = { path = "../puffin-interpreter" } diff --git a/crates/puffin-workspace/Cargo.toml b/crates/puffin-workspace/Cargo.toml index 314c10a6a..39266f873 100644 --- a/crates/puffin-workspace/Cargo.toml +++ b/crates/puffin-workspace/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep440_rs = { path = "../pep440-rs" } pep508_rs = { path = "../pep508-rs" } diff --git a/crates/pypi-types/Cargo.toml b/crates/pypi-types/Cargo.toml index 9559659e1..b8da14ff0 100644 --- a/crates/pypi-types/Cargo.toml +++ b/crates/pypi-types/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep440_rs = { path = "../pep440-rs", features = ["serde"] } pep508_rs = { path = "../pep508-rs", features = ["serde"] } diff --git a/crates/requirements-txt/Cargo.toml b/crates/requirements-txt/Cargo.toml index 4395ad2fe..11ea19f72 100644 --- a/crates/requirements-txt/Cargo.toml +++ b/crates/requirements-txt/Cargo.toml @@ -9,6 +9,9 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[lints] +workspace = true + [dependencies] pep440_rs = { path = "../pep440-rs", features = ["serde"] } pep508_rs = { path = "../pep508-rs", features = ["serde"] } diff --git a/crates/requirements-txt/src/lib.rs b/crates/requirements-txt/src/lib.rs index 3c23446af..f207a4642 100644 --- a/crates/requirements-txt/src/lib.rs +++ b/crates/requirements-txt/src/lib.rs @@ -489,7 +489,7 @@ mod test { let working_dir = workspace_test_data_dir().join("requirements-txt"); let requirements_txt = working_dir.join(path); - let actual = RequirementsTxt::parse(&requirements_txt, &working_dir).unwrap(); + let actual = RequirementsTxt::parse(requirements_txt, &working_dir).unwrap(); let snapshot = format!("parse-{}", path.to_string_lossy()); insta::assert_debug_snapshot!(snapshot, actual); @@ -521,7 +521,7 @@ mod test { // Write to a new file. let temp_dir = tempdir().unwrap(); let requirements_txt = temp_dir.path().join(path); - fs::write(&requirements_txt, &contents).unwrap(); + fs::write(&requirements_txt, contents).unwrap(); let actual = RequirementsTxt::parse(&requirements_txt, &working_dir).unwrap(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 50fa4928b..71326c3d7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.73" +channel = "1.74"