Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate standard lints into a cargo config file #3386

Merged
merged 4 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

[target.'cfg(all())']
rustflags = [
# Zebra standard lints for Rust 1.58+
"-Dunsafe_code",
"-Drust_2021_compatibility",
"-Dclippy::await_holding_lock",

"-Wmissing_docs",
"-Wnonstandard_style",
"-Wfuture_incompatible",

"-Aclippy::try_err",

# TODOs:

# fix hidden lifetime parameters
#"-Wrust_2018_idioms",
]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
# Vscode detrius
.vscode/
.zebra-state/
.cargo/
# Nix configs
shell.nix
7 changes: 0 additions & 7 deletions tower-batch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@
//! control logic, as it will receive explicit [`Flush`](BatchControl::Flush)
//! requests from the wrapper.

// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

pub mod error;
pub mod future;
mod layer;
Expand Down
6 changes: 0 additions & 6 deletions tower-batch/tests/ed25519.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use std::{
future::Future,
mem,
Expand Down
6 changes: 0 additions & 6 deletions tower-batch/tests/worker.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use std::time::Duration;
use tokio_test::{assert_pending, assert_ready, assert_ready_err, task};
use tower::{Service, ServiceExt};
Expand Down
7 changes: 0 additions & 7 deletions tower-fallback/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
//!
//! [aws-fallback]: https://aws.amazon.com/builders-library/avoiding-fallback-in-distributed-systems/

// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

pub mod future;
mod service;

Expand Down
6 changes: 0 additions & 6 deletions tower-fallback/tests/fallback.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use tower::{service_fn, Service, ServiceExt};
use tower_fallback::Fallback;

Expand Down
6 changes: 1 addition & 5 deletions zebra-chain/benches/block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Standard lints
// Disabled due to warnings in criterion macros
//#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]
#![allow(missing_docs)]

use std::io::Cursor;

Expand Down
3 changes: 2 additions & 1 deletion zebra-chain/benches/redpallas.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Benchmarks for batch verifiication of RedPallas signatures.

use std::convert::TryFrom;
// Disabled due to warnings in criterion macros
#![allow(missing_docs)]

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use rand::{thread_rng, Rng};
Expand Down
5 changes: 5 additions & 0 deletions zebra-chain/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build script for zebra-chain.
//!
//! Turns the environmental variable `$TEST_FAKE_ACTIVATION_HEIGHTS`
//! into the Rust configuration `cfg(test_fake_activation_heights)`.

use std::env;

fn main() {
Expand Down
6 changes: 0 additions & 6 deletions zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_chain")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
// Required by bitvec! macro
#![recursion_limit = "256"]

Expand Down
6 changes: 0 additions & 6 deletions zebra-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_client")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
7 changes: 0 additions & 7 deletions zebra-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")]
// Standard lints
// Warn on missing docs for all modules after cleaning the API surface
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

mod block;
mod checkpoint;
Expand Down
6 changes: 0 additions & 6 deletions zebra-network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_network")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

#[macro_use]
extern crate pin_project;
Expand Down
6 changes: 0 additions & 6 deletions zebra-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_rpc")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
12 changes: 4 additions & 8 deletions zebra-script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_script")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
// we allow unsafe code, so we can call zcash_script

use std::{convert::TryInto, sync::Arc};
// We allow unsafe code, so we can call zcash_script
#![allow(unsafe_code)]

use std::sync::Arc;

use displaydoc::Display;
use thiserror::Error;
Expand Down
5 changes: 5 additions & 0 deletions zebra-state/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build script for zebra-state.
//!
//! Turns the environmental variable `$TEST_FAKE_ACTIVATION_HEIGHTS`
//! into the Rust configuration `cfg(test_fake_activation_heights)`.

use std::env;

fn main() {
Expand Down
6 changes: 0 additions & 6 deletions zebra-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_state")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]

#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
Expand Down
6 changes: 0 additions & 6 deletions zebra-state/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use color_eyre::eyre::Report;
use once_cell::sync::Lazy;
use std::sync::Arc;
Expand Down
6 changes: 0 additions & 6 deletions zebra-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_test")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
// Each lazy_static variable uses additional recursion
#![recursion_limit = "512"]

Expand Down
3 changes: 3 additions & 0 deletions zebra-test/src/service_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ use tower::{Service, ServiceExt};
/// An extension trait to check if a [`Service`] is immediately ready to be called.
pub trait IsReady<Request>: Service<Request> {
/// Poll the [`Service`] once, and return true if it is immediately ready to be called.
#[allow(clippy::wrong_self_convention)]
fn is_ready(&mut self) -> BoxFuture<bool>;

/// Poll the [`Service`] once, and return true if it is pending.
#[allow(clippy::wrong_self_convention)]
fn is_pending(&mut self) -> BoxFuture<bool>;

/// Poll the [`Service`] once, and return true if it has failed.
#[allow(clippy::wrong_self_convention)]
fn is_failed(&mut self) -> BoxFuture<bool>;
}

Expand Down
6 changes: 0 additions & 6 deletions zebra-test/tests/command.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use std::{process::Command, time::Duration};

use color_eyre::eyre::Result;
Expand Down
6 changes: 0 additions & 6 deletions zebra-test/tests/transcript.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use tower::{Service, ServiceExt};
use zebra_test::transcript::ExpectedTranscriptError;
use zebra_test::transcript::Transcript;
Expand Down
6 changes: 0 additions & 6 deletions zebra-utils/src/bin/zebra-checkpoints/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
//! zebra-consensus accepts an ordered list of checkpoints, starting with the
//! genesis block. Checkpoint heights can be chosen arbitrarily.

// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use color_eyre::eyre::{ensure, Result};
use serde_json::Value;
use std::process::Stdio;
Expand Down
6 changes: 0 additions & 6 deletions zebra-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,3 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_utils")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
5 changes: 5 additions & 0 deletions zebrad/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build script for zebrad.
//!
//! Turns Zebra version information into build-time environmental variables,
//! so that it can be compiled into `zebrad`, and used in diagnostics.

use vergen::{vergen, Config, SemverKind, ShaKind};

/// Disable vergen env vars that could cause spurious reproducible build
Expand Down
6 changes: 0 additions & 6 deletions zebrad/src/bin/zebrad/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
//! Main entry point for Zebrad

// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use zebrad::application::APPLICATION;

/// Boot Zebrad
Expand Down
6 changes: 0 additions & 6 deletions zebrad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebrad")]
// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![deny(rust_2021_compatibility)]
#![forbid(unsafe_code)]
// Tracing causes false positives on this lint:
// https://github.com/tokio-rs/tracing/issues/553
#![allow(clippy::cognitive_complexity)]
Expand Down
6 changes: 0 additions & 6 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
//! or you have poor network connectivity,
//! skip all the network tests by setting the `ZEBRA_SKIP_NETWORK_TESTS` environmental variable.

// Standard lints
#![warn(missing_docs)]
#![allow(clippy::try_err)]
#![deny(clippy::await_holding_lock)]
#![forbid(unsafe_code)]

use color_eyre::{
eyre::{Result, WrapErr},
Help,
Expand Down