Skip to content

Commit a8367e0

Browse files
authored
Fix clippy lints (#549)
1 parent 020086f commit a8367e0

File tree

14 files changed

+29
-34
lines changed

14 files changed

+29
-34
lines changed

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ features = ["serde"]
7070
criterion = "0.5.1"
7171
temptree = "0.2.0"
7272

73+
[lints.clippy]
74+
all = { level = "deny", priority = -1 }
75+
float_cmp = "allow"
76+
large_enum_variant = "allow"
77+
needless_pass_by_value = "allow"
78+
pedantic = { level = "deny", priority = -1 }
79+
struct_excessive_bools = "allow"
80+
too_many_lines = "allow"
81+
wildcard_imports = "allow"
82+
7383
[workspace]
7484
members = [
7585
# generate documentation

build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
io::{self, Error, ErrorKind},
2+
io::{self, Error},
33
process::Command,
44
};
55

@@ -13,7 +13,7 @@ fn is_inside_git_work_tree() -> bool {
1313
}
1414

1515
fn error(message: String) -> io::Error {
16-
Error::new(ErrorKind::Other, message)
16+
Error::other(message)
1717
}
1818

1919
fn commit_hash() -> io::Result<String> {
@@ -33,8 +33,7 @@ fn commit_hash() -> io::Result<String> {
3333

3434
if !hash.chars().all(|c| "0123456789abcdef".contains(c)) {
3535
return Err(error(format!(
36-
"Invalid hash from `git rev-parse HEAD`: {}",
37-
hash
36+
"Invalid hash from `git rev-parse HEAD`: {hash}",
3837
)));
3938
}
4039

@@ -47,7 +46,7 @@ fn main() -> io::Result<()> {
4746
println!("cargo:rustc-env=GIT_HEAD_PARTIAL_HASH= ({})", &hash[0..12]);
4847
} else {
4948
println!("cargo:rustc-env=GIT_HEAD_PARTIAL_HASH=");
50-
};
49+
}
5150

5251
Ok(())
5352
}

src/file_error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ impl Print for FileError {
8989
Self::Surfeit(difference) => write!(stream, "{difference} too long")?,
9090
Self::Dearth(difference) => write!(stream, "{difference} too short")?,
9191
Self::Md5 { .. } => {
92-
return Err(io::Error::new(
93-
io::ErrorKind::Other,
92+
return Err(io::Error::other(
9493
Error::internal("Reached unreachable branch").to_string(),
9594
))
9695
}

src/input_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl TryFrom<&OsStr> for InputTarget {
2020
fn try_from(text: &OsStr) -> Result<Self, Self::Error> {
2121
if text.is_empty() {
2222
return Err(Error::InputTargetEmpty);
23-
};
23+
}
2424

2525
if text == OsStr::new("-") {
2626
Ok(Self::Stdin)

src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
#![deny(clippy::all, clippy::pedantic)]
2-
#![allow(
3-
clippy::float_cmp,
4-
clippy::needless_lifetimes,
5-
clippy::needless_pass_by_value,
6-
clippy::non_ascii_literal,
7-
clippy::struct_excessive_bools,
8-
clippy::too_many_lines,
9-
clippy::unseparated_literal_suffix,
10-
clippy::wildcard_imports,
11-
clippy::large_enum_variant,
12-
clippy::module_name_repetitions
13-
)]
14-
151
pub use run::run;
162

173
#[cfg(test)]

src/metainfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Metainfo {
9999
self.info.content_size()
100100
}
101101

102-
pub(crate) fn trackers<'a>(&'a self) -> impl Iterator<Item = Result<Url>> + 'a {
102+
pub(crate) fn trackers(&self) -> impl Iterator<Item = Result<Url>> + '_ {
103103
let mut seen = HashSet::new();
104104
iter::once(&self.announce)
105105
.flatten()

src/output_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl TryFrom<&OsStr> for OutputTarget {
2727
fn try_from(text: &OsStr) -> Result<Self, Self::Error> {
2828
if text.is_empty() {
2929
return Err(Error::OutputTargetEmpty);
30-
};
30+
}
3131

3232
if text == OsStr::new("-") {
3333
Ok(Self::Stdout)

src/peer/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Client {
9797
{
9898
return Err(Error::PeerUtMetadataNotSupported);
9999
}
100-
};
100+
}
101101

102102
self.extension_handshake.replace(handshake);
103103

@@ -117,7 +117,7 @@ impl Client {
117117
extended::ut_metadata::MsgType::Request | extended::ut_metadata::MsgType::Reject => {
118118
return Ok(())
119119
}
120-
};
120+
}
121121

122122
if let State::WantInfo(info_buf) = &mut self.state {
123123
let piece = info_buf.len() / extended::UtMetadata::PIECE_LENGTH;
@@ -667,7 +667,7 @@ mod tests {
667667

668668
assert_matches!(
669669
join_handle.join().unwrap(),
670-
Err(Error::PeerUtMetadataInfoLength { .. })
670+
Err(Error::PeerUtMetadataInfoLength)
671671
);
672672
}
673673
}

src/subcommand/torrent/create/create_step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) enum CreateStep<'a> {
77
Writing { output: &'a OutputTarget },
88
}
99

10-
impl<'a> Step for CreateStep<'a> {
10+
impl Step for CreateStep<'_> {
1111
fn n(&self) -> usize {
1212
match self {
1313
Self::Searching { .. } => 1,

src/subcommand/torrent/dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn fmt_string(f: &mut Formatter, string: &[u8]) -> fmt::Result {
4646
Ok(())
4747
}
4848

49-
impl<'a> Display for Fmt<'a> {
49+
impl Display for Fmt<'_> {
5050
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
5151
match &self.0 {
5252
Value::Integer(integer) => write!(f, "{integer}")?,

0 commit comments

Comments
 (0)