diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 1e6872bd69..93f619b7b5 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -1,5 +1,3 @@ -# Disabled - this workflow needs more work so it's not incredibly chatty -## ## Perform Clippy checks - currently set to defaults ## https://github.com/rust-lang/rust-clippy#usage ## https://rust-lang.github.io/rust-clippy/master/index.html @@ -17,10 +15,10 @@ on: types: - opened - reopened + - synchronize jobs: clippy_check: - if: ${{ false }} name: Clippy Check runs-on: ubuntu-latest steps: @@ -41,4 +39,4 @@ jobs: uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features + args: -p clarity -p libstackerdb -p pox-locking -p stacks-common --no-deps --tests --all-features -- -D warnings diff --git a/Cargo.lock b/Cargo.lock index 6f0d0c6217..333d246c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -450,6 +450,28 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.64.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 1.0.109", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -584,6 +606,15 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -636,6 +667,17 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "2.34.0" @@ -1112,23 +1154,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -1417,6 +1448,12 @@ version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "gloo-timers" version = "0.2.6" @@ -1877,11 +1914,17 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.140" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libflate" @@ -1903,6 +1946,16 @@ dependencies = [ "rle-decode-fast", ] +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if 1.0.0", + "winapi 0.3.9", +] + [[package]] name = "libsigner" version = "0.0.1" @@ -1963,6 +2016,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + [[package]] name = "log" version = "0.4.17" @@ -2022,6 +2081,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -2134,6 +2199,16 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2268,7 +2343,10 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "p256k1" version = "5.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e81c2cb5a1936d3f26278f9d698932239d03ddf0d5818392d91cd5f98ffc79" dependencies = [ + "bindgen", "bitvec", "bs58 0.4.0", "cc", @@ -2317,6 +2395,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.2.0" @@ -2879,6 +2963,12 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -2935,10 +3025,23 @@ dependencies = [ "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", "windows-sys 0.45.0", ] +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.21.7" @@ -3283,6 +3386,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "simple-mutex" version = "1.1.5" @@ -3671,7 +3780,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", - "rustix", + "rustix 0.37.7", "windows-sys 0.45.0", ] @@ -4352,6 +4461,18 @@ version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.28", +] + [[package]] name = "winapi" version = "0.2.8" @@ -4428,6 +4549,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -4458,6 +4588,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -4470,6 +4615,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -4482,6 +4633,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -4494,6 +4651,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -4506,6 +4669,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -4518,6 +4687,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -4530,6 +4705,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -4542,6 +4723,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.15" @@ -4574,6 +4761,8 @@ dependencies = [ [[package]] name = "wsts" version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0c0ec44cbd35be82490c8c566ad4971f7b41ffe8508f1c9938140df7fe18b2" dependencies = [ "aes-gcm 0.10.2", "bs58 0.5.0", diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml index 86089991dc..e83c77f823 100644 --- a/clarity/Cargo.toml +++ b/clarity/Cargo.toml @@ -15,7 +15,7 @@ resolver = "2" [lib] name = "clarity" -path = "./src/libclarity.rs" +path = "./src/lib.rs" [dependencies] rand = "0.7.3" diff --git a/clarity/src/libclarity.rs b/clarity/src/lib.rs similarity index 100% rename from clarity/src/libclarity.rs rename to clarity/src/lib.rs diff --git a/clarity/src/vm/analysis/errors.rs b/clarity/src/vm/analysis/errors.rs index 9aeb878f2d..81ae521c95 100644 --- a/clarity/src/vm/analysis/errors.rs +++ b/clarity/src/vm/analysis/errors.rs @@ -216,7 +216,7 @@ impl CheckError { pub fn set_expressions(&mut self, exprs: &[SymbolicExpression]) { self.diagnostic.spans = exprs.iter().map(|e| e.span().clone()).collect(); - self.expressions.replace(exprs.clone().to_vec()); + self.expressions.replace(exprs.to_vec()); } } diff --git a/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs b/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs index 22b87e4256..59488e8056 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs @@ -1441,7 +1441,7 @@ fn test_response_inference() { fn test_function_arg_names() { use crate::vm::analysis::type_check; - let functions = vec![ + let functions = [ "(define-private (test (x int)) (ok 0)) (define-public (test-pub (x int)) (ok 0)) (define-read-only (test-ro (x int)) (ok 0))", diff --git a/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs b/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs index 24263c7a8d..fd9b4df5fa 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs @@ -2239,7 +2239,7 @@ fn test_response_inference(#[case] version: ClarityVersion, #[case] epoch: Stack fn test_function_arg_names() { use crate::vm::analysis::type_check; - let functions = vec![ + let functions = [ "(define-private (test (x int)) (ok 0)) (define-public (test-pub (x int)) (ok 0)) (define-read-only (test-ro (x int)) (ok 0))", diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index 7bfa61b7f1..d5c2167992 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -44,7 +44,7 @@ use crate::vm::types::QualifiedContractIdentifier; use crate::vm::ClarityVersion; /// Legacy function -#[cfg(any(test, features = "testing"))] +#[cfg(any(test, feature = "testing"))] pub fn parse( contract_identifier: &QualifiedContractIdentifier, source_code: &str, diff --git a/clarity/src/vm/ast/parser/v1.rs b/clarity/src/vm/ast/parser/v1.rs index d3cfb2c62c..7ba15cfc97 100644 --- a/clarity/src/vm/ast/parser/v1.rs +++ b/clarity/src/vm/ast/parser/v1.rs @@ -132,11 +132,11 @@ lazy_static! { static ref lex_matchers: Vec = vec![ LexMatcher::new( - r##"u"(?P((\\")|([[ -~]&&[^"]]))*)""##, + r#"u"(?P((\\")|([[ -~]&&[^"]]))*)""#, TokenType::StringUTF8Literal, ), LexMatcher::new( - r##""(?P((\\")|([[ -~]&&[^"]]))*)""##, + r#""(?P((\\")|([[ -~]&&[^"]]))*)""#, TokenType::StringASCIILiteral, ), LexMatcher::new(";;[ -~]*", TokenType::Whitespace), // ;; comments. diff --git a/clarity/src/vm/ast/parser/v2/mod.rs b/clarity/src/vm/ast/parser/v2/mod.rs index 582bfe14e0..4032f7fa72 100644 --- a/clarity/src/vm/ast/parser/v2/mod.rs +++ b/clarity/src/vm/ast/parser/v2/mod.rs @@ -236,7 +236,7 @@ impl<'a> Parser<'a> { Token::Rparen => { span.end_line = token.span.end_line; span.end_column = token.span.end_column; - let out_nodes: Vec<_> = nodes.drain(..).collect(); + let out_nodes: Vec<_> = std::mem::take(nodes); let mut e = PreSymbolicExpression::list(out_nodes.into_boxed_slice()); e.copy_span(span); Ok(Some(e)) @@ -253,7 +253,7 @@ impl<'a> Parser<'a> { )?; span.end_line = token.span.end_line; span.end_column = token.span.end_column; - let out_nodes: Vec<_> = nodes.drain(..).collect(); + let out_nodes: Vec<_> = std::mem::take(nodes); let mut e = PreSymbolicExpression::list(out_nodes.into_boxed_slice()); e.copy_span(span); Ok(Some(e)) diff --git a/libsigner/Cargo.toml b/libsigner/Cargo.toml index 8500ef55fa..35aaca69f7 100644 --- a/libsigner/Cargo.toml +++ b/libsigner/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" [lib] name = "libsigner" -path = "./src/libsigner.rs" +path = "./src/lib.rs" [dependencies] clarity = { path = "../clarity" } diff --git a/libsigner/src/libsigner.rs b/libsigner/src/lib.rs similarity index 100% rename from libsigner/src/libsigner.rs rename to libsigner/src/lib.rs diff --git a/stacks-common/Cargo.toml b/stacks-common/Cargo.toml index 863a82d53c..650446ea25 100644 --- a/stacks-common/Cargo.toml +++ b/stacks-common/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" [lib] name = "stacks_common" -path = "./src/libcommon.rs" +path = "./src/lib.rs" [dependencies] rand = "0.7.3" diff --git a/stacks-common/src/libcommon.rs b/stacks-common/src/lib.rs similarity index 99% rename from stacks-common/src/libcommon.rs rename to stacks-common/src/lib.rs index f759e9ca34..a53f7db984 100644 --- a/stacks-common/src/libcommon.rs +++ b/stacks-common/src/lib.rs @@ -13,6 +13,7 @@ extern crate rand; extern crate rusqlite; extern crate secp256k1; extern crate serde; + #[macro_use] extern crate lazy_static; extern crate ripemd; diff --git a/stacks-common/src/types/net.rs b/stacks-common/src/types/net.rs index 45b6fb43ef..25c86a82de 100644 --- a/stacks-common/src/types/net.rs +++ b/stacks-common/src/types/net.rs @@ -107,9 +107,7 @@ impl PeerAddress { /// order. Return None if this is not an IPv4 address. pub fn ipv4_bits(&self) -> Option { let octets_opt = self.ipv4_octets(); - if octets_opt.is_none() { - return None; - } + octets_opt?; let octets = octets_opt.unwrap(); Some( @@ -291,8 +289,8 @@ impl FromStr for PeerHost { // try as DNS-name:port let host; let port; - let parts: Vec<&str> = header.split(":").collect(); - if parts.len() == 0 { + let parts: Vec<&str> = header.split(':').collect(); + if parts.is_empty() { return Err(Error::DecodeError( "Failed to parse PeerHost: no parts".to_string(), )); @@ -305,7 +303,7 @@ impl FromStr for PeerHost { if parts[np - 1].chars().all(char::is_numeric) { // ends in :port let host_str = parts[0..np - 1].join(":"); - if host_str.len() == 0 { + if host_str.is_empty() { return Err(Error::DecodeError("Empty host".to_string())); } host = Some(host_str); diff --git a/stacks-common/src/util/hash.rs b/stacks-common/src/util/hash.rs index f365aaa508..c98d801092 100644 --- a/stacks-common/src/util/hash.rs +++ b/stacks-common/src/util/hash.rs @@ -605,20 +605,15 @@ pub fn hex_bytes(s: &str) -> Result, HexError> { let mut v = vec![]; let mut iter = s.chars().pair(); // Do the parsing - iter.by_ref().fold(Ok(()), |e, (f, s)| { - if e.is_err() { - e - } else { - match (f.to_digit(16), s.to_digit(16)) { - (None, _) => Err(HexError::BadCharacter(f)), - (_, None) => Err(HexError::BadCharacter(s)), - (Some(f), Some(s)) => { - v.push((f * 0x10 + s) as u8); - Ok(()) - } + iter.by_ref() + .try_fold((), |_, (f, s)| match (f.to_digit(16), s.to_digit(16)) { + (None, _) => Err(HexError::BadCharacter(f)), + (_, None) => Err(HexError::BadCharacter(s)), + (Some(f), Some(s)) => { + v.push((f * 0x10 + s) as u8); + Ok(()) } - } - })?; + })?; // Check that there was no remainder match iter.remainder() { Some(_) => Err(HexError::BadLength(s.len())), diff --git a/stacks-common/src/util/log.rs b/stacks-common/src/util/log.rs index 0889fc6a8f..3aa2a1e5af 100644 --- a/stacks-common/src/util/log.rs +++ b/stacks-common/src/util/log.rs @@ -238,8 +238,7 @@ fn make_logger() -> Logger { let plain = slog_term::PlainSyncDecorator::new(slog_term::TestStdoutWriter); let isatty = isatty(Stream::Stdout); let drain = TermFormat::new(plain, false, debug, isatty); - let logger = Logger::root(drain.ignore_res(), o!()); - logger + Logger::root(drain.ignore_res(), o!()) } } diff --git a/stacks-common/src/util/macros.rs b/stacks-common/src/util/macros.rs index 16320c948d..3a683b19f4 100644 --- a/stacks-common/src/util/macros.rs +++ b/stacks-common/src/util/macros.rs @@ -355,11 +355,10 @@ macro_rules! impl_array_newtype { } } - #[cfg_attr(feature = "clippy", allow(expl_impl_clone_on_copy))] // we don't define the `struct`, we have to explicitly impl impl Clone for $thing { #[inline] fn clone(&self) -> $thing { - $thing::from(&self[..]) + *self } } diff --git a/stacks-common/src/util/pipe.rs b/stacks-common/src/util/pipe.rs index d850826fd4..87cf461b8f 100644 --- a/stacks-common/src/util/pipe.rs +++ b/stacks-common/src/util/pipe.rs @@ -402,8 +402,7 @@ mod test { #[test] fn test_connection_pipe_producer_consumer() { - let mut buf = Vec::new(); - buf.resize(1048576, 0); + let mut buf = vec![0; 1048576]; let mut rng = rand::thread_rng(); rng.fill_bytes(&mut buf);