From 753cbc96263714d065ec92353923f1abbff3f67c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 4 Nov 2021 11:13:29 -0400 Subject: [PATCH] In rust-nightly CI, forbid debugging prints. This patch makes the rust-nightly CI task fail if it detects any dbg!(), println!(), or eprintln!() calls in production code. Because of clippy limitations, it may also gripe about calls to these macros in our tests. The preferred workarounds are to either instead. Both are acceptable. We're doing this check in CI rather than unconditionally with clippy directives, since we often want to have these calls in our code temporarily while we're developing. Some day we might want this test to go into a pre-push hook. This patch also adds #![allow()] directives for println!() and eprintln!() in the arti crate. Since that one isn't a library, it's okay for it to speak to stdout/stderr. Closes #218. --- .gitlab-ci.yml | 3 ++- crates/arti/src/main.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8aaa0ac1c..60d1b1bb2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,7 +40,8 @@ rust-nightly: - cargo build --verbose --target x86_64-unknown-linux-gnu --all-features - cargo test --verbose --all-features - rustup component add clippy - - cargo clippy --all-features + # We check these extra warnings on CI only, since we don't want to forbid them while developing. + - cargo clippy --all-features -- -D clippy::dbg_macro -D clippy::print_stdout -D clippy::print_stderr - RUSTDOCFLAGS="-Dwarnings" cargo doc --all-features --document-private-items tags: - amd64 diff --git a/crates/arti/src/main.rs b/crates/arti/src/main.rs index 9604d4be2..aef472119 100644 --- a/crates/arti/src/main.rs +++ b/crates/arti/src/main.rs @@ -82,6 +82,9 @@ #![deny(clippy::unnecessary_wraps)] #![warn(clippy::unseparated_literal_suffix)] #![deny(clippy::unwrap_used)] +// These are allowed in this crate only. +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] mod exit; mod process;