Skip to content

Commit

Permalink
Auto merge of #12178 - weihanglo:dogfood-lints-table, r=epage
Browse files Browse the repository at this point in the history
chore: dogfood Cargo `-Zlints` table feature
  • Loading branch information
bors committed Nov 16, 2023
2 parents 85273ad + e2f5925 commit 9f3b488
Show file tree
Hide file tree
Showing 45 changed files with 133 additions and 47 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions benches/benchsuite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ harness = false
[[bench]]
name = "global_cache_tracker"
harness = false

[lints]
workspace = true
2 changes: 2 additions & 0 deletions benches/benchsuite/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::disallowed_methods)]

use cargo::Config;
use std::fs;
use std::path::{Path, PathBuf};
Expand Down
3 changes: 3 additions & 0 deletions benches/capture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ cargo_metadata.workspace = true
flate2.workspace = true
tar.workspace = true
toml.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions benches/capture/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
//! 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)]
#![allow(clippy::print_stderr)]

use flate2::{Compression, GzBuilder};
use std::fs;
use std::path::{Path, PathBuf};
Expand Down
5 changes: 4 additions & 1 deletion crates/cargo-platform/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,3 +11,6 @@ description = "Cargo's representation of a target platform."

[dependencies]
serde.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/cargo-platform/examples/matches.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 3 additions & 0 deletions crates/cargo-test-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ publish = false

[lib]
proc-macro = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/cargo-test-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ walkdir.workspace = true

[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = ["Win32_Storage_FileSystem"] }

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/cargo-test-support/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::disallowed_methods)]

fn main() {
println!(
"cargo:rustc-env=NATIVE_ARCH={}",
Expand Down
4 changes: 3 additions & 1 deletion crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//!
//! See <https://rust-lang.github.io/cargo/contrib/> for a guide on writing tests.
#![allow(clippy::all)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::print_stderr)]
#![allow(clippy::print_stdout)]

use std::env;
use std::ffi::OsStr;
Expand Down
3 changes: 3 additions & 0 deletions crates/cargo-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions crates/cargo-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion crates/crates-io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,3 +20,6 @@ serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
thiserror.workspace = true
url.workspace = true

[lints]
workspace = true
2 changes: 0 additions & 2 deletions crates/crates-io/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::all)]

use std::collections::BTreeMap;
use std::fs::File;
use std::io::prelude::*;
Expand Down
5 changes: 4 additions & 1 deletion crates/home/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "home"
version = "0.5.8"
version = "0.5.9"
authors = ["Brian Anderson <[email protected]>"]
rust-version = "1.70.0" # MSRV:3
documentation = "https://docs.rs/home"
Expand All @@ -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
2 changes: 1 addition & 1 deletion crates/home/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//!
//! [discussion]: https://github.com/rust-lang/rust/pull/46799#issuecomment-361156935
#![deny(rust_2018_idioms)]
#![allow(clippy::disallowed_methods)]

pub mod env;

Expand Down
3 changes: 3 additions & 0 deletions crates/mdman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ url.workspace = true

[dev-dependencies]
pretty_assertions.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/mdman/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::print_stderr)]

use anyhow::{bail, format_err, Context, Error};
use mdman::{Format, ManMap};
use std::collections::HashMap;
Expand Down
2 changes: 2 additions & 0 deletions crates/mdman/tests/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions crates/resolver-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ cargo.workspace = true
cargo-util.workspace = true
proptest.workspace = true
varisat.workspace = true

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/resolver-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::all)]
#![allow(clippy::print_stderr)]

use std::cell::RefCell;
use std::cmp::PartialEq;
Expand Down
3 changes: 3 additions & 0 deletions crates/semver-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ publish = false

[dependencies]
tempfile.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/semver-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions crates/xtask-build-man/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition.workspace = true
publish = false

[dependencies]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/xtask-build-man/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//! For more, read their doc comments.
//! ```
#![allow(clippy::print_stderr)]

use std::fs;
use std::io;
use std::path::PathBuf;
Expand Down
3 changes: 3 additions & 0 deletions crates/xtask-bump-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ git2.workspace = true
semver.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/xtask-stale-label/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ publish = false

[dependencies]
toml_edit.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/xtask-stale-label/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions credential/cargo-credential-1password/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions credential/cargo-credential-1password/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Cargo registry 1password credential process.
#![allow(clippy::disallowed_methods)]
#![allow(clippy::print_stderr)]

use cargo_credential::{
Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, Secret,
};
Expand Down
5 changes: 4 additions & 1 deletion credential/cargo-credential-libsecret/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Loading

0 comments on commit 9f3b488

Please sign in to comment.