diff --git a/Cargo.toml b/Cargo.toml index 5f71551..afba35e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,16 @@ features = ["serde"] criterion = "0.5.1" temptree = "0.2.0" +[lints.clippy] +all = { level = "deny", priority = -1 } +float_cmp = "allow" +large_enum_variant = "allow" +needless_pass_by_value = "allow" +pedantic = { level = "deny", priority = -1 } +struct_excessive_bools = "allow" +too_many_lines = "allow" +wildcard_imports = "allow" + [workspace] members = [ # generate documentation diff --git a/build.rs b/build.rs index 0b3f2f2..db14a8b 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ use std::{ - io::{self, Error, ErrorKind}, + io::{self, Error}, process::Command, }; @@ -13,7 +13,7 @@ fn is_inside_git_work_tree() -> bool { } fn error(message: String) -> io::Error { - Error::new(ErrorKind::Other, message) + Error::other(message) } fn commit_hash() -> io::Result { @@ -33,8 +33,7 @@ fn commit_hash() -> io::Result { if !hash.chars().all(|c| "0123456789abcdef".contains(c)) { return Err(error(format!( - "Invalid hash from `git rev-parse HEAD`: {}", - hash + "Invalid hash from `git rev-parse HEAD`: {hash}", ))); } @@ -47,7 +46,7 @@ fn main() -> io::Result<()> { println!("cargo:rustc-env=GIT_HEAD_PARTIAL_HASH= ({})", &hash[0..12]); } else { println!("cargo:rustc-env=GIT_HEAD_PARTIAL_HASH="); - }; + } Ok(()) } diff --git a/src/file_error.rs b/src/file_error.rs index 8d6ef68..b0620a3 100644 --- a/src/file_error.rs +++ b/src/file_error.rs @@ -89,8 +89,7 @@ impl Print for FileError { Self::Surfeit(difference) => write!(stream, "{difference} too long")?, Self::Dearth(difference) => write!(stream, "{difference} too short")?, Self::Md5 { .. } => { - return Err(io::Error::new( - io::ErrorKind::Other, + return Err(io::Error::other( Error::internal("Reached unreachable branch").to_string(), )) } diff --git a/src/input_target.rs b/src/input_target.rs index 64e8991..9e3703d 100644 --- a/src/input_target.rs +++ b/src/input_target.rs @@ -20,7 +20,7 @@ impl TryFrom<&OsStr> for InputTarget { fn try_from(text: &OsStr) -> Result { if text.is_empty() { return Err(Error::InputTargetEmpty); - }; + } if text == OsStr::new("-") { Ok(Self::Stdin) diff --git a/src/lib.rs b/src/lib.rs index 455e808..ce9d445 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,17 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] -#![allow( - clippy::float_cmp, - clippy::needless_lifetimes, - clippy::needless_pass_by_value, - clippy::non_ascii_literal, - clippy::struct_excessive_bools, - clippy::too_many_lines, - clippy::unseparated_literal_suffix, - clippy::wildcard_imports, - clippy::large_enum_variant, - clippy::module_name_repetitions -)] - pub use run::run; #[cfg(test)] diff --git a/src/metainfo.rs b/src/metainfo.rs index 6f671c0..9e4098b 100644 --- a/src/metainfo.rs +++ b/src/metainfo.rs @@ -99,7 +99,7 @@ impl Metainfo { self.info.content_size() } - pub(crate) fn trackers<'a>(&'a self) -> impl Iterator> + 'a { + pub(crate) fn trackers(&self) -> impl Iterator> + '_ { let mut seen = HashSet::new(); iter::once(&self.announce) .flatten() diff --git a/src/output_target.rs b/src/output_target.rs index e695e80..ed29f46 100644 --- a/src/output_target.rs +++ b/src/output_target.rs @@ -27,7 +27,7 @@ impl TryFrom<&OsStr> for OutputTarget { fn try_from(text: &OsStr) -> Result { if text.is_empty() { return Err(Error::OutputTargetEmpty); - }; + } if text == OsStr::new("-") { Ok(Self::Stdout) diff --git a/src/peer/client.rs b/src/peer/client.rs index ad5b3f8..5c419a1 100644 --- a/src/peer/client.rs +++ b/src/peer/client.rs @@ -97,7 +97,7 @@ impl Client { { return Err(Error::PeerUtMetadataNotSupported); } - }; + } self.extension_handshake.replace(handshake); @@ -117,7 +117,7 @@ impl Client { extended::ut_metadata::MsgType::Request | extended::ut_metadata::MsgType::Reject => { return Ok(()) } - }; + } if let State::WantInfo(info_buf) = &mut self.state { let piece = info_buf.len() / extended::UtMetadata::PIECE_LENGTH; @@ -667,7 +667,7 @@ mod tests { assert_matches!( join_handle.join().unwrap(), - Err(Error::PeerUtMetadataInfoLength { .. }) + Err(Error::PeerUtMetadataInfoLength) ); } } diff --git a/src/subcommand/torrent/create/create_step.rs b/src/subcommand/torrent/create/create_step.rs index 3a6b175..b94d76d 100644 --- a/src/subcommand/torrent/create/create_step.rs +++ b/src/subcommand/torrent/create/create_step.rs @@ -7,7 +7,7 @@ pub(crate) enum CreateStep<'a> { Writing { output: &'a OutputTarget }, } -impl<'a> Step for CreateStep<'a> { +impl Step for CreateStep<'_> { fn n(&self) -> usize { match self { Self::Searching { .. } => 1, diff --git a/src/subcommand/torrent/dump.rs b/src/subcommand/torrent/dump.rs index 5f9e808..ddbc1b2 100644 --- a/src/subcommand/torrent/dump.rs +++ b/src/subcommand/torrent/dump.rs @@ -46,7 +46,7 @@ fn fmt_string(f: &mut Formatter, string: &[u8]) -> fmt::Result { Ok(()) } -impl<'a> Display for Fmt<'a> { +impl Display for Fmt<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match &self.0 { Value::Integer(integer) => write!(f, "{integer}")?, diff --git a/src/subcommand/torrent/stats.rs b/src/subcommand/torrent/stats.rs index ae68326..22188ea 100644 --- a/src/subcommand/torrent/stats.rs +++ b/src/subcommand/torrent/stats.rs @@ -260,7 +260,8 @@ impl Extractor { } else { buffer.push('<'); for byte in string { - buffer.push_str(&format!("{byte:02X}")); + use std::fmt::Write; + write!(buffer, "{byte:02X}").unwrap(); } buffer.push('>'); } diff --git a/src/subcommand/torrent/verify/verify_step.rs b/src/subcommand/torrent/verify/verify_step.rs index 2add3b3..96704e8 100644 --- a/src/subcommand/torrent/verify/verify_step.rs +++ b/src/subcommand/torrent/verify/verify_step.rs @@ -6,7 +6,7 @@ pub(crate) enum VerifyStep<'a> { Verifying { content: &'a Path }, } -impl<'a> Step for VerifyStep<'a> { +impl Step for VerifyStep<'_> { fn n(&self) -> usize { match self { Self::Loading { .. } => 1, diff --git a/src/torrent_summary.rs b/src/torrent_summary.rs index ddbf746..cd2ec1e 100644 --- a/src/torrent_summary.rs +++ b/src/torrent_summary.rs @@ -165,7 +165,7 @@ impl TorrentSummary { .collect(), ); } - }; + } table } diff --git a/src/tracker/client.rs b/src/tracker/client.rs index 320cf55..7b476cb 100644 --- a/src/tracker/client.rs +++ b/src/tracker/client.rs @@ -284,13 +284,13 @@ mod tests { #[test] fn client_connect_timeout_ipv4() { let (_, addr, _) = TestServer::new_ipv4(); - assert_matches!(Client::connect(addr), Err(Error::TrackerNoHosts { .. })); + assert_matches!(Client::connect(addr), Err(Error::TrackerNoHosts)); } #[test] fn client_connect_timeout_ipv6() { let (_, addr, _) = TestServer::new_ipv6(); - assert_matches!(Client::connect(addr), Err(Error::TrackerNoHosts { .. })); + assert_matches!(Client::connect(addr), Err(Error::TrackerNoHosts)); } #[test]