Skip to content

Commit 64a344d

Browse files
authored
Merge pull request #700 from cgwalters/minor-local-buildstuff
build: Use workspace global lints
2 parents f00395c + 63bcf63 commit 64a344d

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ jobs:
4141
run: cd lib && cargo check --no-default-features
4242
- name: Individual checks
4343
run: (cd cli && cargo check) && (cd lib && cargo check)
44-
- name: Lints
45-
run: cargo xtask custom-lints
4644
- name: Run tests
4745
run: cargo test -- --nocapture --quiet
4846
- name: Manpage generation

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@ exclude-crate-paths = [ { name = "libz-sys", exclude = "src/zlib" },
4747
{ name = "k8s-openapi", exclude = "src/v1_25" },
4848
{ name = "k8s-openapi", exclude = "src/v1_27" },
4949
]
50+
51+
[workspace.lints.rust]
52+
# Require an extra opt-in for unsafe
53+
unsafe_code = "deny"
54+
# Absolutely must handle errors
55+
unused_must_use = "forbid"
56+
57+
[workspace.lints.clippy]
58+
# These should only be in local code
59+
dbg_macro = "deny"
60+
todo = "deny"

cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ tokio = { workspace = true, features = ["macros"] }
2424
log = "0.4.21"
2525
tracing = { workspace = true }
2626
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
27+
28+
[lints]
29+
workspace = true

cli/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// Good defaults
2-
#![forbid(unused_must_use)]
3-
#![deny(unsafe_code)]
4-
51
use anyhow::Result;
62

73
async fn run() -> Result<()> {

lib/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ install = []
5858
# Implementation detail of man page generation.
5959
docgen = ["clap_mangen"]
6060

61+
[lints]
62+
workspace = true

lib/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
// See https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
88
#![deny(missing_docs)]
99
#![deny(missing_debug_implementations)]
10-
#![forbid(unused_must_use)]
11-
#![deny(unsafe_code)]
1210
#![cfg_attr(feature = "dox", feature(doc_cfg))]
13-
#![deny(clippy::dbg_macro)]
14-
#![deny(clippy::todo)]
1511
// These two are in my experience the lints which are most likely
1612
// to trigger, and among the least valuable to fix.
1713
#![allow(clippy::needless_borrow)]

tests-integration/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ serde = { workspace = true, features = ["derive"] }
2424
serde_json = { workspace = true }
2525
tempfile = { workspace = true }
2626
xshell = { version = "0.2.6" }
27+
28+
[lints]
29+
workspace = true

xtask/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ fn-error-context = { workspace = true }
1919
tempfile = { workspace = true }
2020
mandown = "0.1.3"
2121
xshell = { version = "0.2.6" }
22+
23+
[lints]
24+
workspace = true

xtask/src/xtask.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fs::File;
2-
use std::io::{BufRead, BufReader, BufWriter, Cursor, Write};
2+
use std::io::{BufRead, BufReader, BufWriter, Write};
33
use std::process::{Command, Stdio};
44

55
use anyhow::{anyhow, Context, Result};
@@ -23,7 +23,6 @@ const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
2323
("package", package),
2424
("package-srpm", package_srpm),
2525
("spec", spec),
26-
("custom-lints", custom_lints),
2726
("test-tmt", test_tmt),
2827
];
2928

@@ -356,18 +355,6 @@ fn package_srpm(sh: &Shell) -> Result<()> {
356355
Ok(())
357356
}
358357

359-
fn custom_lints(sh: &Shell) -> Result<()> {
360-
// Verify there are no invocations of the dbg macro.
361-
let o = cmd!(sh, "git grep dbg\x21 *.rs").ignore_status().read()?;
362-
if !o.is_empty() {
363-
let mut stderr = std::io::stderr().lock();
364-
std::io::copy(&mut Cursor::new(o.as_bytes()), &mut stderr)?;
365-
eprintln!();
366-
anyhow::bail!("Found dbg\x21 macro");
367-
}
368-
Ok(())
369-
}
370-
371358
fn print_help(_sh: &Shell) -> Result<()> {
372359
println!("Tasks:");
373360
for (name, _) in TASKS {

0 commit comments

Comments
 (0)