Skip to content
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
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
io::{self, Error, ErrorKind},
io::{self, Error},
process::Command,
};

Expand All @@ -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<String> {
Expand All @@ -33,8 +33,7 @@ fn commit_hash() -> io::Result<String> {

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}",
)));
}

Expand All @@ -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(())
}
3 changes: 1 addition & 2 deletions src/file_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))
}
Expand Down
2 changes: 1 addition & 1 deletion src/input_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl TryFrom<&OsStr> for InputTarget {
fn try_from(text: &OsStr) -> Result<Self, Self::Error> {
if text.is_empty() {
return Err(Error::InputTargetEmpty);
};
}

if text == OsStr::new("-") {
Ok(Self::Stdin)
Expand Down
14 changes: 0 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/metainfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Metainfo {
self.info.content_size()
}

pub(crate) fn trackers<'a>(&'a self) -> impl Iterator<Item = Result<Url>> + 'a {
pub(crate) fn trackers(&self) -> impl Iterator<Item = Result<Url>> + '_ {
let mut seen = HashSet::new();
iter::once(&self.announce)
.flatten()
Expand Down
2 changes: 1 addition & 1 deletion src/output_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl TryFrom<&OsStr> for OutputTarget {
fn try_from(text: &OsStr) -> Result<Self, Self::Error> {
if text.is_empty() {
return Err(Error::OutputTargetEmpty);
};
}

if text == OsStr::new("-") {
Ok(Self::Stdout)
Expand Down
6 changes: 3 additions & 3 deletions src/peer/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Client {
{
return Err(Error::PeerUtMetadataNotSupported);
}
};
}

self.extension_handshake.replace(handshake);

Expand All @@ -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;
Expand Down Expand Up @@ -667,7 +667,7 @@ mod tests {

assert_matches!(
join_handle.join().unwrap(),
Err(Error::PeerUtMetadataInfoLength { .. })
Err(Error::PeerUtMetadataInfoLength)
);
}
}
2 changes: 1 addition & 1 deletion src/subcommand/torrent/create/create_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/torrent/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")?,
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/torrent/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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('>');
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/torrent/verify/verify_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/torrent_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl TorrentSummary {
.collect(),
);
}
};
}

table
}
Expand Down
4 changes: 2 additions & 2 deletions src/tracker/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading