Consolidate standard lints into a cargo config file (#3386)

* Move standard lints into .cargo/config.toml

* Ignore "wrong self convention" in a futures-based trait

This lint might only trigger on beta or nightly at the moment.

* Warn if future incompatibile code is added to Zebra

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
teor 2022-01-25 02:25:06 +10:00 committed by GitHub
parent 3cc896feaf
commit 00aa5d96a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 43 additions and 137 deletions

19
.cargo/config.toml Normal file
View File

@ -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
.gitignore vendored
View File

@ -10,6 +10,5 @@
# Vscode detrius
.vscode/
.zebra-state/
.cargo/
# Nix configs
shell.nix

View File

@ -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;

View File

@ -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,

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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};

View File

@ -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() {

View File

@ -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"]

View File

@ -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)]

View File

@ -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;

View File

@ -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;

View File

@ -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)]

View File

@ -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
// We allow unsafe code, so we can call zcash_script
#![allow(unsafe_code)]
use std::{convert::TryInto, sync::Arc};
use std::sync::Arc;
use displaydoc::Display;
use thiserror::Error;

View File

@ -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() {

View File

@ -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;

View File

@ -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;

View File

@ -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"]

View File

@ -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>;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)]

View File

@ -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

View File

@ -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

View File

@ -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)]

View File

@ -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,