Fix warnings and clippy errors

type: reform
This commit is contained in:
Casey Rodarmor 2021-07-02 20:19:16 -07:00
parent 2346c30fec
commit 379a001f47
No known key found for this signature in database
GPG Key ID: 556186B153EC6FE0
13 changed files with 28 additions and 34 deletions

View File

@ -63,14 +63,9 @@ jobs:
target target
key: cargo-${{ env.CACHE_KEY }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} key: cargo-${{ env.CACHE_KEY }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Stable - name: Install Rust Toolchain Components
uses: actions-rs/toolchain@v1 run: |
with: rustup component add clippy rustfmt
toolchain: stable
target: ${{matrix.target}}
profile: minimal
components: clippy, rustfmt
override: true
- name: Info - name: Info
run: | run: |

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
1.51.0

View File

@ -7,8 +7,8 @@ const TI: u64 = GI << 10;
const PI: u64 = TI << 10; const PI: u64 = TI << 10;
const EI: u64 = PI << 10; const EI: u64 = PI << 10;
#[serde(transparent)]
#[derive(Debug, PartialEq, Copy, Clone, PartialOrd, Ord, Eq, Serialize, Deserialize, Default)] #[derive(Debug, PartialEq, Copy, Clone, PartialOrd, Ord, Eq, Serialize, Deserialize, Default)]
#[serde(transparent)]
pub(crate) struct Bytes(pub(crate) u64); pub(crate) struct Bytes(pub(crate) u64);
impl Bytes { impl Bytes {
@ -89,7 +89,7 @@ impl FromStr for Bytes {
_ => { _ => {
return Err(Error::ByteSuffix { return Err(Error::ByteSuffix {
text: text.to_owned(), text: text.to_owned(),
suffix: suffix.to_owned(), suffix: suffix.clone(),
}) })
} }
}; };

View File

@ -41,7 +41,7 @@ impl Env {
.and_then(|width| width.parse::<usize>().ok()); .and_then(|width| width.parse::<usize>().ok());
if let Some(width) = width { if let Some(width) = width {
app = app.set_term_width(width) app = app.set_term_width(width);
} }
app app

View File

@ -1,7 +1,7 @@
use crate::common::*; use crate::common::*;
#[serde(transparent)]
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone, Ord, PartialOrd, Eq)] #[derive(Deserialize, Serialize, Debug, PartialEq, Clone, Ord, PartialOrd, Eq)]
#[serde(transparent)]
pub(crate) struct FilePath { pub(crate) struct FilePath {
components: Vec<String>, components: Vec<String>,
} }

View File

@ -12,7 +12,7 @@ impl Linter {
} }
pub(crate) fn allow(&mut self, allowed: impl IntoIterator<Item = Lint>) { pub(crate) fn allow(&mut self, allowed: impl IntoIterator<Item = Lint>) {
self.allowed.extend(allowed) self.allowed.extend(allowed);
} }
pub(crate) fn is_allowed(&self, lint: Lint) -> bool { pub(crate) fn is_allowed(&self, lint: Lint) -> bool {

View File

@ -1,7 +1,7 @@
use crate::common::*; use crate::common::*;
#[serde(transparent)]
#[derive(Deserialize, Serialize, Debug, Eq, PartialEq, Copy, Clone)] #[derive(Deserialize, Serialize, Debug, Eq, PartialEq, Copy, Clone)]
#[serde(transparent)]
pub(crate) struct Md5Digest { pub(crate) struct Md5Digest {
#[serde(with = "SerHex::<serde_hex::Strict>")] #[serde(with = "SerHex::<serde_hex::Strict>")]
bytes: [u8; 16], bytes: [u8; 16],

View File

@ -1,7 +1,7 @@
use crate::common::*; use crate::common::*;
#[serde(untagged)]
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)] #[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
#[serde(untagged)]
pub(crate) enum Mode { pub(crate) enum Mode {
Single { Single {
length: Bytes, length: Bytes,

View File

@ -1,10 +1,10 @@
use crate::common::*; use crate::common::*;
pub(crate) struct OutputStream { pub(crate) struct OutputStream {
active: bool,
stream: Box<dyn Write>, stream: Box<dyn Write>,
style: bool, style: bool,
term: bool, term: bool,
active: bool,
} }
impl OutputStream { impl OutputStream {

View File

@ -62,6 +62,6 @@ mod tests {
#[test] #[test]
fn variants() { fn variants() {
assert_eq!(Shell::VARIANTS, clap::Shell::variants()) assert_eq!(Shell::VARIANTS, clap::Shell::variants());
} }
} }

View File

@ -338,9 +338,7 @@ impl Create {
if let OutputTarget::Path(path) = &output { if let OutputTarget::Path(path) = &output {
if !self.force && path.exists() { if !self.force && path.exists() {
return Err(Error::OutputExists { return Err(Error::OutputExists { path: path.clone() });
path: path.to_owned(),
});
} }
} }
@ -1151,7 +1149,7 @@ mod tests {
length: Bytes(3), length: Bytes(3),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1182,7 +1180,7 @@ mod tests {
length: Bytes(4), length: Bytes(4),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1213,7 +1211,7 @@ mod tests {
length: Bytes(4), length: Bytes(4),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1258,7 +1256,7 @@ mod tests {
}, },
], ],
} }
) );
} }
#[test] #[test]
@ -1285,7 +1283,7 @@ mod tests {
length: Bytes(3), length: Bytes(3),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1319,7 +1317,7 @@ mod tests {
length: Bytes(3), length: Bytes(3),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1346,7 +1344,7 @@ mod tests {
length: Bytes(0), length: Bytes(0),
md5sum: None, md5sum: None,
} }
) );
} }
#[test] #[test]
@ -1367,7 +1365,7 @@ mod tests {
env.assert_ok(); env.assert_ok();
let metainfo = env.load_metainfo("foo.torrent"); let metainfo = env.load_metainfo("foo.torrent");
assert_eq!(metainfo.info.pieces.count(), 0); assert_eq!(metainfo.info.pieces.count(), 0);
assert_eq!(metainfo.info.mode, Mode::Multiple { files: Vec::new() }) assert_eq!(metainfo.info.mode, Mode::Multiple { files: Vec::new() });
} }
#[test] #[test]

View File

@ -37,19 +37,19 @@ macro_rules! test_env {
pub(crate) struct TestEnv { pub(crate) struct TestEnv {
env: Env, env: Env,
#[allow(unused)]
tempdir: TempDir,
err: Capture, err: Capture,
out: Capture, out: Capture,
#[allow(unused)]
tempdir: TempDir,
} }
impl TestEnv { impl TestEnv {
pub(crate) fn new(tempdir: TempDir, env: Env, err: Capture, out: Capture) -> TestEnv { pub(crate) fn new(tempdir: TempDir, env: Env, err: Capture, out: Capture) -> TestEnv {
Self { Self {
tempdir,
err,
env, env,
err,
out, out,
tempdir,
} }
} }

View File

@ -177,7 +177,7 @@ impl TorrentSummary {
fn torrent_summary_data(&self) -> TorrentSummaryJson { fn torrent_summary_data(&self) -> TorrentSummaryJson {
let (file_count, files) = match &self.metainfo.info.mode { let (file_count, files) = match &self.metainfo.info.mode {
Mode::Single { .. } => (1, vec![self.metainfo.info.name.to_owned()]), Mode::Single { .. } => (1, vec![self.metainfo.info.name.clone()]),
Mode::Multiple { files } => ( Mode::Multiple { files } => (
files.len(), files.len(),
files files
@ -197,7 +197,7 @@ impl TorrentSummary {
}; };
TorrentSummaryJson { TorrentSummaryJson {
name: self.metainfo.info.name.to_owned(), name: self.metainfo.info.name.clone(),
comment: self.metainfo.comment.clone(), comment: self.metainfo.comment.clone(),
creation_date: self.metainfo.creation_date, creation_date: self.metainfo.creation_date,
created_by: self.metainfo.created_by.clone(), created_by: self.metainfo.created_by.clone(),