From 1539b3dfc197fd7ced9174613d2c0317b7a45107 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 24 May 2023 22:25:07 +0100 Subject: [PATCH 1/6] lint: dogfood ourselves `lints` table in manifest These lint rules are from src/lib.rs. We aim to remove them in the source code once `Zlints` hit stable. --- Cargo.toml | 17 +++++++++++++++++ benches/benchsuite/Cargo.toml | 3 +++ benches/capture/Cargo.toml | 3 +++ crates/cargo-platform/Cargo.toml | 3 +++ crates/cargo-test-macro/Cargo.toml | 3 +++ crates/cargo-test-support/Cargo.toml | 3 +++ crates/cargo-test-support/src/lib.rs | 2 -- crates/cargo-util/Cargo.toml | 3 +++ crates/crates-io/Cargo.toml | 3 +++ crates/crates-io/lib.rs | 2 -- crates/home/Cargo.toml | 3 +++ crates/home/src/lib.rs | 2 -- crates/mdman/Cargo.toml | 3 +++ crates/resolver-tests/Cargo.toml | 3 +++ crates/resolver-tests/src/lib.rs | 2 -- crates/semver-check/Cargo.toml | 3 +++ crates/xtask-build-man/Cargo.toml | 3 +++ crates/xtask-bump-check/Cargo.toml | 3 +++ crates/xtask-stale-label/Cargo.toml | 3 +++ .../cargo-credential-1password/Cargo.toml | 3 +++ .../cargo-credential-libsecret/Cargo.toml | 3 +++ .../cargo-credential-macos-keychain/Cargo.toml | 3 +++ credential/cargo-credential-wincred/Cargo.toml | 3 +++ credential/cargo-credential/Cargo.toml | 3 +++ src/bin/cargo/main.rs | 4 ---- src/cargo/lib.rs | 14 -------------- src/cargo/util/errors.rs | 2 -- tests/testsuite/main.rs | 4 ---- 28 files changed, 74 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f3a75b091ebe..63e294d6dfcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,20 @@ varisat = "0.2.2" walkdir = "2.4.0" windows-sys = "0.48" +[workspace.lints.rust] +rust_2018_idioms = "warn" # TODO: could this be removed? + +[workspace.lints.rustdoc] +private_intra_doc_links = "allow" + +[workspace.lints.clippy] +all = { level = "allow", priority = -1 } +dbg_macro = "warn" +disallowed_methods = "warn" +print_stderr = "warn" +print_stdout = "warn" +self_named_module_files = "warn" + [package] name = "cargo" version = "0.77.0" @@ -234,3 +248,6 @@ vendored-openssl = ["openssl/vendored"] vendored-libgit2 = ["libgit2-sys/vendored"] # This is primarily used by rust-lang/rust distributing cargo the executable. all-static = ['vendored-openssl', 'curl/static-curl', 'curl/force-system-lib-on-osx'] + +[lints] +workspace = true diff --git a/benches/benchsuite/Cargo.toml b/benches/benchsuite/Cargo.toml index 2887290ed4dd..25c1604385fd 100644 --- a/benches/benchsuite/Cargo.toml +++ b/benches/benchsuite/Cargo.toml @@ -32,3 +32,6 @@ harness = false [[bench]] name = "global_cache_tracker" harness = false + +[lints] +workspace = true diff --git a/benches/capture/Cargo.toml b/benches/capture/Cargo.toml index e300815d5a24..16f2c5071e46 100644 --- a/benches/capture/Cargo.toml +++ b/benches/capture/Cargo.toml @@ -12,3 +12,6 @@ cargo_metadata.workspace = true flate2.workspace = true tar.workspace = true toml.workspace = true + +[lints] +workspace = true diff --git a/crates/cargo-platform/Cargo.toml b/crates/cargo-platform/Cargo.toml index 786948ff3a4f..17b4369b18a5 100644 --- a/crates/cargo-platform/Cargo.toml +++ b/crates/cargo-platform/Cargo.toml @@ -11,3 +11,6 @@ description = "Cargo's representation of a target platform." [dependencies] serde.workspace = true + +[lints] +workspace = true diff --git a/crates/cargo-test-macro/Cargo.toml b/crates/cargo-test-macro/Cargo.toml index 1e81ab314a20..17ca326f6f24 100644 --- a/crates/cargo-test-macro/Cargo.toml +++ b/crates/cargo-test-macro/Cargo.toml @@ -12,3 +12,6 @@ publish = false [lib] proc-macro = true + +[lints] +workspace = true diff --git a/crates/cargo-test-support/Cargo.toml b/crates/cargo-test-support/Cargo.toml index 42f8c2af915d..1098d598d603 100644 --- a/crates/cargo-test-support/Cargo.toml +++ b/crates/cargo-test-support/Cargo.toml @@ -33,3 +33,6 @@ walkdir.workspace = true [target.'cfg(windows)'.dependencies] windows-sys = { workspace = true, features = ["Win32_Storage_FileSystem"] } + +[lints] +workspace = true diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index ec74ce0b2065..053211f8d353 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -2,8 +2,6 @@ //! //! See for a guide on writing tests. -#![allow(clippy::all)] - use std::env; use std::ffi::OsStr; use std::fmt::Write; diff --git a/crates/cargo-util/Cargo.toml b/crates/cargo-util/Cargo.toml index 42d2c3733317..3fd6bdeca171 100644 --- a/crates/cargo-util/Cargo.toml +++ b/crates/cargo-util/Cargo.toml @@ -28,3 +28,6 @@ core-foundation.workspace = true [target.'cfg(windows)'.dependencies] miow.workspace = true windows-sys = { workspace = true, features = ["Win32_Storage_FileSystem", "Win32_Foundation", "Win32_System_Console"] } + +[lints] +workspace = true diff --git a/crates/crates-io/Cargo.toml b/crates/crates-io/Cargo.toml index f1b92602e9d4..507f1bae1faf 100644 --- a/crates/crates-io/Cargo.toml +++ b/crates/crates-io/Cargo.toml @@ -20,3 +20,6 @@ serde = { workspace = true, features = ["derive"] } serde_json.workspace = true thiserror.workspace = true url.workspace = true + +[lints] +workspace = true diff --git a/crates/crates-io/lib.rs b/crates/crates-io/lib.rs index 1764ce527de1..b2a42378e1d1 100644 --- a/crates/crates-io/lib.rs +++ b/crates/crates-io/lib.rs @@ -1,5 +1,3 @@ -#![allow(clippy::all)] - use std::collections::BTreeMap; use std::fs::File; use std::io::prelude::*; diff --git a/crates/home/Cargo.toml b/crates/home/Cargo.toml index 702a14e552ee..0759122ce40f 100644 --- a/crates/home/Cargo.toml +++ b/crates/home/Cargo.toml @@ -18,3 +18,6 @@ description = "Shared definitions of home directories." [target.'cfg(windows)'.dependencies] windows-sys = { workspace = true, features = ["Win32_Foundation", "Win32_UI_Shell"] } + +[lints] +workspace = true diff --git a/crates/home/src/lib.rs b/crates/home/src/lib.rs index 4aee7383bca2..9737e17e716a 100644 --- a/crates/home/src/lib.rs +++ b/crates/home/src/lib.rs @@ -18,8 +18,6 @@ //! //! [discussion]: https://github.com/rust-lang/rust/pull/46799#issuecomment-361156935 -#![deny(rust_2018_idioms)] - pub mod env; #[cfg(target_os = "windows")] diff --git a/crates/mdman/Cargo.toml b/crates/mdman/Cargo.toml index fd33da3c2011..95adc0cb158c 100644 --- a/crates/mdman/Cargo.toml +++ b/crates/mdman/Cargo.toml @@ -17,3 +17,6 @@ url.workspace = true [dev-dependencies] pretty_assertions.workspace = true + +[lints] +workspace = true diff --git a/crates/resolver-tests/Cargo.toml b/crates/resolver-tests/Cargo.toml index 8750a3d972f5..947c445698ea 100644 --- a/crates/resolver-tests/Cargo.toml +++ b/crates/resolver-tests/Cargo.toml @@ -10,3 +10,6 @@ cargo.workspace = true cargo-util.workspace = true proptest.workspace = true varisat.workspace = true + +[lints] +workspace = true diff --git a/crates/resolver-tests/src/lib.rs b/crates/resolver-tests/src/lib.rs index 507bff943c4c..26c3f370763c 100644 --- a/crates/resolver-tests/src/lib.rs +++ b/crates/resolver-tests/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(clippy::all)] - use std::cell::RefCell; use std::cmp::PartialEq; use std::cmp::{max, min}; diff --git a/crates/semver-check/Cargo.toml b/crates/semver-check/Cargo.toml index 7387c3091ceb..ab13b5730514 100644 --- a/crates/semver-check/Cargo.toml +++ b/crates/semver-check/Cargo.toml @@ -10,3 +10,6 @@ publish = false [dependencies] tempfile.workspace = true + +[lints] +workspace = true diff --git a/crates/xtask-build-man/Cargo.toml b/crates/xtask-build-man/Cargo.toml index 9e92125a147b..87ae8c670a08 100644 --- a/crates/xtask-build-man/Cargo.toml +++ b/crates/xtask-build-man/Cargo.toml @@ -6,3 +6,6 @@ edition.workspace = true publish = false [dependencies] + +[lints] +workspace = true diff --git a/crates/xtask-bump-check/Cargo.toml b/crates/xtask-bump-check/Cargo.toml index c8a472adcc4c..989ece4b70cb 100644 --- a/crates/xtask-bump-check/Cargo.toml +++ b/crates/xtask-bump-check/Cargo.toml @@ -14,3 +14,6 @@ git2.workspace = true semver.workspace = true tracing-subscriber.workspace = true tracing.workspace = true + +[lints] +workspace = true diff --git a/crates/xtask-stale-label/Cargo.toml b/crates/xtask-stale-label/Cargo.toml index 8d68536d25b8..aff6194b7cd6 100644 --- a/crates/xtask-stale-label/Cargo.toml +++ b/crates/xtask-stale-label/Cargo.toml @@ -7,3 +7,6 @@ publish = false [dependencies] toml_edit.workspace = true + +[lints] +workspace = true diff --git a/credential/cargo-credential-1password/Cargo.toml b/credential/cargo-credential-1password/Cargo.toml index 24dfdd930ffd..0e6b0b00bfaf 100644 --- a/credential/cargo-credential-1password/Cargo.toml +++ b/credential/cargo-credential-1password/Cargo.toml @@ -11,3 +11,6 @@ description = "A Cargo credential process that stores tokens in a 1password vaul cargo-credential.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true + +[lints] +workspace = true diff --git a/credential/cargo-credential-libsecret/Cargo.toml b/credential/cargo-credential-libsecret/Cargo.toml index 4c13128006c0..ad4eb48599bc 100644 --- a/credential/cargo-credential-libsecret/Cargo.toml +++ b/credential/cargo-credential-libsecret/Cargo.toml @@ -11,3 +11,6 @@ description = "A Cargo credential process that stores tokens with GNOME libsecre anyhow.workspace = true cargo-credential.workspace = true libloading.workspace = true + +[lints] +workspace = true diff --git a/credential/cargo-credential-macos-keychain/Cargo.toml b/credential/cargo-credential-macos-keychain/Cargo.toml index e217ced45ffb..6acc0236c025 100644 --- a/credential/cargo-credential-macos-keychain/Cargo.toml +++ b/credential/cargo-credential-macos-keychain/Cargo.toml @@ -12,3 +12,6 @@ cargo-credential.workspace = true [target.'cfg(target_os = "macos")'.dependencies] security-framework.workspace = true + +[lints] +workspace = true diff --git a/credential/cargo-credential-wincred/Cargo.toml b/credential/cargo-credential-wincred/Cargo.toml index 3d4dbf978a5a..98b22e1704bf 100644 --- a/credential/cargo-credential-wincred/Cargo.toml +++ b/credential/cargo-credential-wincred/Cargo.toml @@ -13,3 +13,6 @@ cargo-credential.workspace = true [target.'cfg(windows)'.dependencies.windows-sys] features = ["Win32_Foundation", "Win32_Security_Credentials"] workspace = true + +[lints] +workspace = true diff --git a/credential/cargo-credential/Cargo.toml b/credential/cargo-credential/Cargo.toml index 8ba65b8b9e3d..130fea782c63 100644 --- a/credential/cargo-credential/Cargo.toml +++ b/credential/cargo-credential/Cargo.toml @@ -20,3 +20,6 @@ windows-sys = { workspace = true, features = ["Win32_System_Console", "Win32_Fou [dev-dependencies] snapbox = { workspace = true, features = ["examples"] } + +[lints] +workspace = true diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 245622b6c979..64f893ae2aef 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -1,7 +1,3 @@ -#![warn(rust_2018_idioms)] // while we're getting used to 2018 -#![allow(clippy::all)] -#![warn(clippy::disallowed_methods)] - use cargo::util::network::http::http_handle; use cargo::util::network::http::needs_custom_http_transport; use cargo::util::toml::schema::StringOrVec; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 6947642c9ce5..a4049db0b7e9 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -129,20 +129,6 @@ //! [The Cargo Book]: https://doc.rust-lang.org/cargo/ //! [Cargo Contributor Guide]: https://doc.crates.io/contrib/ -// TODO: consider removing these lint attributes when `-Zlints` hits stable. -// For various reasons, some idioms are still allow'ed, but we would like to -// test and enforce them. -#![warn(rust_2018_idioms)] -// Due to some of the default clippy lints being somewhat subjective and not -// necessarily an improvement, we prefer to not use them at this time. -#![allow(clippy::all)] -#![warn(clippy::disallowed_methods)] -#![warn(clippy::self_named_module_files)] -#![warn(clippy::print_stdout)] -#![warn(clippy::print_stderr)] -#![warn(clippy::dbg_macro)] -#![allow(rustdoc::private_intra_doc_links)] - use crate::core::shell::Verbosity::Verbose; use crate::core::Shell; use anyhow::Error; diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 9589e1ae33ec..5752f2370a93 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -1,5 +1,3 @@ -#![allow(unknown_lints)] - use anyhow::Error; use curl::easy::Easy; use std::fmt::{self, Write}; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index e2e46c400a4e..4409596074d0 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -1,7 +1,3 @@ -// See src/cargo/lib.rs for notes on these lint settings. -#![warn(rust_2018_idioms)] -#![allow(clippy::all)] - #[macro_use] extern crate cargo_test_macro; From 870f9ea7b3ec6cea0dc9d21626ec71f367061a2d Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 12 Sep 2023 11:09:07 +0800 Subject: [PATCH 2/6] lint: allow `disallow_methods` --- benches/benchsuite/src/lib.rs | 2 ++ benches/capture/src/main.rs | 2 ++ crates/cargo-test-support/build.rs | 2 ++ crates/cargo-test-support/src/lib.rs | 2 ++ crates/cargo-util/src/lib.rs | 2 ++ crates/home/src/lib.rs | 2 ++ crates/mdman/tests/compare.rs | 2 ++ credential/cargo-credential-1password/src/main.rs | 2 ++ tests/build-std/main.rs | 2 ++ tests/testsuite/main.rs | 2 ++ 10 files changed, 20 insertions(+) diff --git a/benches/benchsuite/src/lib.rs b/benches/benchsuite/src/lib.rs index e470a03b9534..f27710841912 100644 --- a/benches/benchsuite/src/lib.rs +++ b/benches/benchsuite/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::disallowed_methods)] + use cargo::Config; use std::fs; use std::path::{Path, PathBuf}; diff --git a/benches/capture/src/main.rs b/benches/capture/src/main.rs index f6f02c4ba051..f0e670b31c9a 100644 --- a/benches/capture/src/main.rs +++ b/benches/capture/src/main.rs @@ -4,6 +4,8 @@ //! Use the `-f` flag to allow it to overwrite existing captures. //! The workspace will be saved in a `.tgz` file in the `../workspaces` directory. +#![allow(clippy::disallowed_methods)] + use flate2::{Compression, GzBuilder}; use std::fs; use std::path::{Path, PathBuf}; diff --git a/crates/cargo-test-support/build.rs b/crates/cargo-test-support/build.rs index 478da7d99f35..8854f461aa62 100644 --- a/crates/cargo-test-support/build.rs +++ b/crates/cargo-test-support/build.rs @@ -1,3 +1,5 @@ +#![allow(clippy::disallowed_methods)] + fn main() { println!( "cargo:rustc-env=NATIVE_ARCH={}", diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 053211f8d353..c3d08ebd1427 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -2,6 +2,8 @@ //! //! See for a guide on writing tests. +#![allow(clippy::disallowed_methods)] + use std::env; use std::ffi::OsStr; use std::fmt::Write; diff --git a/crates/cargo-util/src/lib.rs b/crates/cargo-util/src/lib.rs index 599d7d861c12..717e89ba469f 100644 --- a/crates/cargo-util/src/lib.rs +++ b/crates/cargo-util/src/lib.rs @@ -1,5 +1,7 @@ //! Miscellaneous support code used by Cargo. +#![allow(clippy::disallowed_methods)] + pub use self::read2::read2; pub use du::du; pub use process_builder::ProcessBuilder; diff --git a/crates/home/src/lib.rs b/crates/home/src/lib.rs index 9737e17e716a..380405e22f18 100644 --- a/crates/home/src/lib.rs +++ b/crates/home/src/lib.rs @@ -18,6 +18,8 @@ //! //! [discussion]: https://github.com/rust-lang/rust/pull/46799#issuecomment-361156935 +#![allow(clippy::disallowed_methods)] + pub mod env; #[cfg(target_os = "windows")] diff --git a/crates/mdman/tests/compare.rs b/crates/mdman/tests/compare.rs index 3e679d1278a1..8af53ed6bd7b 100644 --- a/crates/mdman/tests/compare.rs +++ b/crates/mdman/tests/compare.rs @@ -3,6 +3,8 @@ //! Use the MDMAN_BLESS environment variable to automatically update the //! expected output. +#![allow(clippy::disallowed_methods)] + use mdman::{Format, ManMap}; use pretty_assertions::assert_eq; use std::path::PathBuf; diff --git a/credential/cargo-credential-1password/src/main.rs b/credential/cargo-credential-1password/src/main.rs index 921b521456ab..c5b0228e92a2 100644 --- a/credential/cargo-credential-1password/src/main.rs +++ b/credential/cargo-credential-1password/src/main.rs @@ -1,5 +1,7 @@ //! Cargo registry 1password credential process. +#![allow(clippy::disallowed_methods)] + use cargo_credential::{ Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, Secret, }; diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index 47a4bb671c05..9eb69bb56e10 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -18,6 +18,8 @@ //! `CARGO_RUN_BUILD_STD_TESTS` env var to be set to actually run these tests. //! Otherwise the tests are skipped. +#![allow(clippy::disallowed_methods)] + use cargo_test_support::*; use std::env; use std::path::Path; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 4409596074d0..f379b8d6dc1e 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::disallowed_methods)] + #[macro_use] extern crate cargo_test_macro; From 7a4754a1d32e26edca884d8483a09b3d98465c2a Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 12 Sep 2023 11:28:15 +0800 Subject: [PATCH 3/6] lint: allow `print_stdout` and `print_stderr` --- benches/capture/src/main.rs | 1 + crates/cargo-platform/examples/matches.rs | 2 ++ crates/cargo-test-support/src/lib.rs | 2 ++ crates/mdman/src/main.rs | 2 ++ crates/resolver-tests/src/lib.rs | 2 ++ crates/semver-check/src/main.rs | 2 ++ crates/xtask-build-man/src/main.rs | 2 ++ crates/xtask-stale-label/src/main.rs | 2 ++ credential/cargo-credential-1password/src/main.rs | 1 + credential/cargo-credential-macos-keychain/src/lib.rs | 2 ++ credential/cargo-credential/examples/stdout-redirected.rs | 3 +++ credential/cargo-credential/src/lib.rs | 3 +++ tests/testsuite/main.rs | 2 ++ 13 files changed, 26 insertions(+) diff --git a/benches/capture/src/main.rs b/benches/capture/src/main.rs index f0e670b31c9a..dcded3b1a3a8 100644 --- a/benches/capture/src/main.rs +++ b/benches/capture/src/main.rs @@ -5,6 +5,7 @@ //! The workspace will be saved in a `.tgz` file in the `../workspaces` directory. #![allow(clippy::disallowed_methods)] +#![allow(clippy::print_stderr)] use flate2::{Compression, GzBuilder}; use std::fs; diff --git a/crates/cargo-platform/examples/matches.rs b/crates/cargo-platform/examples/matches.rs index 1b438fb110a3..11318a7df554 100644 --- a/crates/cargo-platform/examples/matches.rs +++ b/crates/cargo-platform/examples/matches.rs @@ -1,6 +1,8 @@ //! This example demonstrates how to filter a Platform based on the current //! host target. +#![allow(clippy::print_stdout)] + use cargo_platform::{Cfg, Platform}; use std::process::Command; use std::str::FromStr; diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index c3d08ebd1427..d5d62fc25e49 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -3,6 +3,8 @@ //! See for a guide on writing tests. #![allow(clippy::disallowed_methods)] +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] use std::env; use std::ffi::OsStr; diff --git a/crates/mdman/src/main.rs b/crates/mdman/src/main.rs index facaa5120476..3c09bc4dd83f 100644 --- a/crates/mdman/src/main.rs +++ b/crates/mdman/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::print_stderr)] + use anyhow::{bail, format_err, Context, Error}; use mdman::{Format, ManMap}; use std::collections::HashMap; diff --git a/crates/resolver-tests/src/lib.rs b/crates/resolver-tests/src/lib.rs index 26c3f370763c..9297844998c3 100644 --- a/crates/resolver-tests/src/lib.rs +++ b/crates/resolver-tests/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::print_stderr)] + use std::cell::RefCell; use std::cmp::PartialEq; use std::cmp::{max, min}; diff --git a/crates/semver-check/src/main.rs b/crates/semver-check/src/main.rs index 9ea0d1244a00..edcf59957e4b 100644 --- a/crates/semver-check/src/main.rs +++ b/crates/semver-check/src/main.rs @@ -13,6 +13,8 @@ //! - `dont-deny`: By default tests have a `#![deny(warnings)]`. This option //! avoids this attribute. Note that `#![allow(unused)]` is always added. +#![allow(clippy::print_stderr)] + use std::error::Error; use std::fs; use std::path::Path; diff --git a/crates/xtask-build-man/src/main.rs b/crates/xtask-build-man/src/main.rs index 6680c3783cca..2ab3f098aaa4 100644 --- a/crates/xtask-build-man/src/main.rs +++ b/crates/xtask-build-man/src/main.rs @@ -10,6 +10,8 @@ //! For more, read their doc comments. //! ``` +#![allow(clippy::print_stderr)] + use std::fs; use std::io; use std::path::PathBuf; diff --git a/crates/xtask-stale-label/src/main.rs b/crates/xtask-stale-label/src/main.rs index 88c044b5b962..efcb52d01c1f 100644 --- a/crates/xtask-stale-label/src/main.rs +++ b/crates/xtask-stale-label/src/main.rs @@ -10,6 +10,8 @@ //! Probably autofix them in the future. //! ``` +#![allow(clippy::print_stderr)] + use std::fmt::Write as _; use std::path::PathBuf; use std::process; diff --git a/credential/cargo-credential-1password/src/main.rs b/credential/cargo-credential-1password/src/main.rs index c5b0228e92a2..3e98e1588800 100644 --- a/credential/cargo-credential-1password/src/main.rs +++ b/credential/cargo-credential-1password/src/main.rs @@ -1,6 +1,7 @@ //! Cargo registry 1password credential process. #![allow(clippy::disallowed_methods)] +#![allow(clippy::print_stderr)] use cargo_credential::{ Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, Secret, diff --git a/credential/cargo-credential-macos-keychain/src/lib.rs b/credential/cargo-credential-macos-keychain/src/lib.rs index 9e6d55472e09..8a702a3620c6 100644 --- a/credential/cargo-credential-macos-keychain/src/lib.rs +++ b/credential/cargo-credential-macos-keychain/src/lib.rs @@ -1,5 +1,7 @@ //! Cargo registry macos keychain credential process. +#![allow(clippy::print_stderr)] + #[cfg(target_os = "macos")] mod macos { use cargo_credential::{ diff --git a/credential/cargo-credential/examples/stdout-redirected.rs b/credential/cargo-credential/examples/stdout-redirected.rs index 75a2d16d1eba..fb7c0446cf85 100644 --- a/credential/cargo-credential/examples/stdout-redirected.rs +++ b/credential/cargo-credential/examples/stdout-redirected.rs @@ -1,5 +1,8 @@ //! Provider used for testing redirection of stdout. +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] + use cargo_credential::{Action, Credential, CredentialResponse, Error, RegistryInfo}; struct MyCredential; diff --git a/credential/cargo-credential/src/lib.rs b/credential/cargo-credential/src/lib.rs index 60bce65be543..0888fb402f79 100644 --- a/credential/cargo-credential/src/lib.rs +++ b/credential/cargo-credential/src/lib.rs @@ -37,6 +37,9 @@ #![doc = include_str!("../examples/file-provider.rs")] //! ``` +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] + use serde::{Deserialize, Serialize}; use std::{fmt::Display, io}; use time::OffsetDateTime; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index f379b8d6dc1e..8e2d6dedf769 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -1,4 +1,6 @@ #![allow(clippy::disallowed_methods)] +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] #[macro_use] extern crate cargo_test_macro; From 48ccb1d3b02c34d0554701a1c43f9657335a25ef Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 12 Sep 2023 12:35:03 +0800 Subject: [PATCH 4/6] lint: allow `self_named_module_files` There is a false positive in `src/bin/cargo/commands/build.rs` --- src/bin/cargo/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 64f893ae2aef..a20ee9448e1a 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::self_named_module_files)] // false positive in `commands/build.rs` + use cargo::util::network::http::http_handle; use cargo::util::network::http::needs_custom_http_transport; use cargo::util::toml::schema::StringOrVec; From 68af5090ec210529f718256a26c8ab00ba001571 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 12 Sep 2023 12:37:49 +0800 Subject: [PATCH 5/6] chore: enable clippy check for all workspace members This also remove `RUSTFLAGS: -D warnings` for test, as it seems to be redundant and clippy covers everythings --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b8055223818..53f6ab8ac93e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,9 +66,7 @@ jobs: - uses: actions/checkout@v4 - run: rustup update stable && rustup default stable - run: rustup component add clippy - # Only check cargo lib for now - # TODO: check every members - - run: cargo clippy -p cargo --lib --no-deps -- -D warnings + - run: cargo clippy --workspace --all-targets --no-deps -- -D warnings stale-label: runs-on: ubuntu-latest @@ -110,8 +108,6 @@ jobs: CARGO_PROFILE_TEST_DEBUG: 1 CARGO_INCREMENTAL: 0 CARGO_PUBLIC_NETWORK_TESTS: 1 - # Deny warnings on CI to avoid warnings getting into the codebase. - RUSTFLAGS: -D warnings strategy: matrix: include: From e2f5925bb074f4d9d9fe5be3a8d9bc8fd2a2aa3e Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 16 Nov 2023 11:30:24 -0500 Subject: [PATCH 6/6] chore: bump version for member crates --- Cargo.lock | 18 +++++++++--------- crates/cargo-platform/Cargo.toml | 2 +- crates/crates-io/Cargo.toml | 2 +- crates/home/Cargo.toml | 2 +- .../cargo-credential-1password/Cargo.toml | 2 +- .../cargo-credential-libsecret/Cargo.toml | 2 +- .../cargo-credential-macos-keychain/Cargo.toml | 2 +- credential/cargo-credential-wincred/Cargo.toml | 2 +- credential/cargo-credential/Cargo.toml | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcd36d8f71d4..158acbcc71ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,7 +252,7 @@ dependencies = [ "cargo-credential-libsecret", "cargo-credential-macos-keychain", "cargo-credential-wincred", - "cargo-platform 0.1.6", + "cargo-platform 0.1.7", "cargo-test-macro", "cargo-test-support", "cargo-util", @@ -321,7 +321,7 @@ dependencies = [ [[package]] name = "cargo-credential" -version = "0.4.1" +version = "0.4.2" dependencies = [ "anyhow", "libc", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "cargo-credential-1password" -version = "0.4.1" +version = "0.4.2" dependencies = [ "cargo-credential", "serde", @@ -344,7 +344,7 @@ dependencies = [ [[package]] name = "cargo-credential-libsecret" -version = "0.3.3" +version = "0.3.4" dependencies = [ "anyhow", "cargo-credential", @@ -353,7 +353,7 @@ dependencies = [ [[package]] name = "cargo-credential-macos-keychain" -version = "0.3.2" +version = "0.3.3" dependencies = [ "cargo-credential", "security-framework", @@ -361,7 +361,7 @@ dependencies = [ [[package]] name = "cargo-credential-wincred" -version = "0.3.2" +version = "0.3.3" dependencies = [ "cargo-credential", "windows-sys", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" dependencies = [ "serde", ] @@ -600,7 +600,7 @@ dependencies = [ [[package]] name = "crates-io" -version = "0.39.1" +version = "0.39.2" dependencies = [ "curl", "percent-encoding", @@ -1904,7 +1904,7 @@ dependencies = [ [[package]] name = "home" -version = "0.5.8" +version = "0.5.9" dependencies = [ "windows-sys", ] diff --git a/crates/cargo-platform/Cargo.toml b/crates/cargo-platform/Cargo.toml index 17b4369b18a5..baa179291532 100644 --- a/crates/cargo-platform/Cargo.toml +++ b/crates/cargo-platform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" edition.workspace = true license.workspace = true rust-version = "1.70.0" # MSRV:3 diff --git a/crates/crates-io/Cargo.toml b/crates/crates-io/Cargo.toml index 507f1bae1faf..bf2b20cf7025 100644 --- a/crates/crates-io/Cargo.toml +++ b/crates/crates-io/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crates-io" -version = "0.39.1" +version = "0.39.2" rust-version.workspace = true edition.workspace = true license.workspace = true diff --git a/crates/home/Cargo.toml b/crates/home/Cargo.toml index 0759122ce40f..294bcd56b19f 100644 --- a/crates/home/Cargo.toml +++ b/crates/home/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "home" -version = "0.5.8" +version = "0.5.9" authors = ["Brian Anderson "] rust-version = "1.70.0" # MSRV:3 documentation = "https://docs.rs/home" diff --git a/credential/cargo-credential-1password/Cargo.toml b/credential/cargo-credential-1password/Cargo.toml index 0e6b0b00bfaf..3024bd497ad2 100644 --- a/credential/cargo-credential-1password/Cargo.toml +++ b/credential/cargo-credential-1password/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-1password" -version = "0.4.1" +version = "0.4.2" edition.workspace = true license.workspace = true rust-version = "1.70.0" # MSRV:3 diff --git a/credential/cargo-credential-libsecret/Cargo.toml b/credential/cargo-credential-libsecret/Cargo.toml index ad4eb48599bc..9ae5f7a9709c 100644 --- a/credential/cargo-credential-libsecret/Cargo.toml +++ b/credential/cargo-credential-libsecret/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-libsecret" -version = "0.3.3" +version = "0.3.4" edition.workspace = true license.workspace = true rust-version.workspace = true diff --git a/credential/cargo-credential-macos-keychain/Cargo.toml b/credential/cargo-credential-macos-keychain/Cargo.toml index 6acc0236c025..e87194a3c43b 100644 --- a/credential/cargo-credential-macos-keychain/Cargo.toml +++ b/credential/cargo-credential-macos-keychain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-macos-keychain" -version = "0.3.2" +version = "0.3.3" edition.workspace = true license.workspace = true rust-version.workspace = true diff --git a/credential/cargo-credential-wincred/Cargo.toml b/credential/cargo-credential-wincred/Cargo.toml index 98b22e1704bf..ccec69be26d5 100644 --- a/credential/cargo-credential-wincred/Cargo.toml +++ b/credential/cargo-credential-wincred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-wincred" -version = "0.3.2" +version = "0.3.3" edition.workspace = true license.workspace = true rust-version.workspace = true diff --git a/credential/cargo-credential/Cargo.toml b/credential/cargo-credential/Cargo.toml index 130fea782c63..7dc37ff82ac9 100644 --- a/credential/cargo-credential/Cargo.toml +++ b/credential/cargo-credential/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential" -version = "0.4.1" +version = "0.4.2" edition.workspace = true license.workspace = true rust-version = "1.70.0" # MSRV:3