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

Use the rustc unknown lints attribute #1609

Merged
merged 4 commits into from
Jan 19, 2021
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
13 changes: 5 additions & 8 deletions zebra-chain/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,7 @@ where
mod test {
use super::*;

use std::{
collections::hash_map::RandomState, collections::HashSet, fmt::Debug, iter::FromIterator,
};
use std::{collections::hash_map::RandomState, collections::HashSet, fmt::Debug};

use color_eyre::eyre::Result;

Expand Down Expand Up @@ -601,20 +599,19 @@ mod test {
let another_one = Amount::<NonNegative>::try_from(1)?;
let zero = Amount::<NonNegative>::try_from(0)?;

let hash_set: HashSet<Amount<NonNegative>, RandomState> =
HashSet::from_iter([one].iter().cloned());
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
let hash_set: HashSet<Amount<NonNegative>, RandomState> = [one].iter().cloned().collect();
assert_eq!(hash_set.len(), 1);

let hash_set: HashSet<Amount<NonNegative>, RandomState> =
HashSet::from_iter([one, one].iter().cloned());
[one, one].iter().cloned().collect();
assert_eq!(hash_set.len(), 1, "Amount hashes are consistent");

let hash_set: HashSet<Amount<NonNegative>, RandomState> =
HashSet::from_iter([one, another_one].iter().cloned());
[one, another_one].iter().cloned().collect();
assert_eq!(hash_set.len(), 1, "Amount hashes are by value");

let hash_set: HashSet<Amount<NonNegative>, RandomState> =
HashSet::from_iter([one, zero].iter().cloned());
[one, zero].iter().cloned().collect();
assert_eq!(
hash_set.len(),
2,
Expand Down
7 changes: 6 additions & 1 deletion zebra-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
// #![deny(missing_docs)]
#![allow(clippy::try_err)]
// Disable some broken or unwanted clippy nightly lints
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
#![allow(unknown_lints)]
// Disable old lint warnings on nightly until 1.51 is stable
#![allow(renamed_and_removed_lints)]
// Use the old lint name to build without warnings on stable until 1.51 is stable
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::from_iter_instead_of_collect)]
// The actual lints we want to disable
#![allow(clippy::unnecessary_wraps)]

#[macro_use]
Expand Down
6 changes: 6 additions & 0 deletions zebra-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
//#![deny(missing_docs)]
#![allow(clippy::try_err)]
// Disable some broken or unwanted clippy nightly lints
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
#![allow(unknown_lints)]
// Disable old lint warnings on nightly until 1.51 is stable
#![allow(renamed_and_removed_lints)]
// Use the old lint name to build without warnings on stable until 1.51 is stable
#![allow(clippy::unknown_clippy_lints)]
// The actual lints we want to disable
#![allow(clippy::unnecessary_wraps)]

mod block;
Expand Down
6 changes: 6 additions & 0 deletions zebra-network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@
// https://github.com/tokio-rs/tracing/issues/553
#![allow(clippy::cognitive_complexity)]
// Disable some broken or unwanted clippy nightly lints
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
#![allow(unknown_lints)]
// Disable old lint warnings on nightly until 1.51 is stable
#![allow(renamed_and_removed_lints)]
// Use the old lint name to build without warnings on stable until 1.51 is stable
#![allow(clippy::unknown_clippy_lints)]
// The actual lints we want to disable
#![allow(clippy::unnecessary_wraps)]

#[macro_use]
Expand Down
3 changes: 0 additions & 3 deletions zebra-script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +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_script")]
// Disable some broken or unwanted clippy nightly lints
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::unnecessary_wraps)]

use displaydoc::Display;
#[cfg(windows)]
Expand Down
11 changes: 6 additions & 5 deletions zebra-state/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ impl Config {
(path, opts)
}

/// Construct a config for an ephemeral in memory database
pub fn ephemeral() -> Self {
let mut config = Self::default();
config.ephemeral = true;
config
/// Construct a config for an ephemeral database
pub fn ephemeral() -> Config {
Config {
ephemeral: true,
..Config::default()
}
}

/// Calculate the database's share of `open_file_limit`
Expand Down
7 changes: 6 additions & 1 deletion zebra-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
#![warn(missing_docs)]
#![allow(clippy::try_err)]
// Disable some broken or unwanted clippy nightly lints
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
#![allow(unknown_lints)]
// Disable old lint warnings on nightly until 1.51 is stable
#![allow(renamed_and_removed_lints)]
// Use the old lint name to build without warnings on stable until 1.51 is stable
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::field_reassign_with_default)]
// The actual lints we want to disable
#![allow(clippy::unnecessary_wraps)]

mod config;
Expand Down
3 changes: 0 additions & 3 deletions zebra-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Miscellaneous test code for Zebra.

// Disable some broken or unwanted clippy nightly lints
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::from_iter_instead_of_collect)]
// Each lazy_static variable uses additional recursion
#![recursion_limit = "256"]

Expand Down
14 changes: 5 additions & 9 deletions zebra-test/src/vectors/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use hex::FromHex;
use lazy_static::lazy_static;

use std::{collections::BTreeMap, iter::FromIterator};
use std::collections::BTreeMap;

lazy_static! {

Expand All @@ -22,8 +22,7 @@ lazy_static! {
/// Mainnet blocks, indexed by height
///
/// This is actually a bijective map, the tests ensure that values are unique.
pub static ref MAINNET_BLOCKS: BTreeMap<u32, &'static [u8]> = BTreeMap::from_iter(
[
pub static ref MAINNET_BLOCKS: BTreeMap<u32, &'static [u8]> = [
// Genesis
(0, BLOCK_MAINNET_GENESIS_BYTES.as_ref()),
// BeforeOverwinter
Expand Down Expand Up @@ -62,14 +61,12 @@ lazy_static! {
(975_066, BLOCK_MAINNET_975066_BYTES.as_ref()),
(982_681, BLOCK_MAINNET_982681_BYTES.as_ref()),
// TODO: Canopy and First Halving, see #1099
].iter().cloned()
);
].iter().cloned().collect();

/// Testnet blocks, indexed by height
///
/// This is actually a bijective map, the tests ensure that values are unique.
pub static ref TESTNET_BLOCKS: BTreeMap<u32, &'static [u8]> = BTreeMap::from_iter(
[
pub static ref TESTNET_BLOCKS: BTreeMap<u32, &'static [u8]> = [
// Genesis
(0, BLOCK_TESTNET_GENESIS_BYTES.as_ref()),
// BeforeOverwinter
Expand Down Expand Up @@ -120,8 +117,7 @@ lazy_static! {
// Shielded coinbase
(1_101_629, BLOCK_TESTNET_1101629_BYTES.as_ref()),
// TODO: First Halving, see #1104
].iter().cloned()
);
].iter().cloned().collect();

// Mainnet

Expand Down
18 changes: 10 additions & 8 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#![forbid(unsafe_code)]
#![allow(dead_code)]
#![allow(clippy::try_err)]
// Disable some broken or unwanted clippy nightly lints
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::field_reassign_with_default)]

use color_eyre::eyre::Result;
use eyre::WrapErr;
Expand All @@ -42,11 +39,16 @@ use zebrad::config::ZebradConfig;
const LAUNCH_DELAY: Duration = Duration::from_secs(3);

fn default_test_config() -> Result<ZebradConfig> {
let mut config = ZebradConfig::default();
config.state = zebra_state::Config::ephemeral();
config.network.listen_addr = "127.0.0.1:0".parse()?;

Ok(config)
let auto_port_ipv4_local = zebra_network::Config {
listen_addr: "127.0.0.1:0".parse()?,
..zebra_network::Config::default()
};
let local_ephemeral = ZebradConfig {
state: zebra_state::Config::ephemeral(),
network: auto_port_ipv4_local,
..ZebradConfig::default()
};
Ok(local_ephemeral)
}

fn persistent_test_config() -> Result<ZebradConfig> {
Expand Down