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
key: cargo-${{ env.CACHE_KEY }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{matrix.target}}
profile: minimal
components: clippy, rustfmt
override: true
- name: Install Rust Toolchain Components
run: |
rustup component add clippy rustfmt
- name: Info
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 EI: u64 = PI << 10;
#[serde(transparent)]
#[derive(Debug, PartialEq, Copy, Clone, PartialOrd, Ord, Eq, Serialize, Deserialize, Default)]
#[serde(transparent)]
pub(crate) struct Bytes(pub(crate) u64);
impl Bytes {
@ -89,7 +89,7 @@ impl FromStr for Bytes {
_ => {
return Err(Error::ByteSuffix {
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());
if let Some(width) = width {
app = app.set_term_width(width)
app = app.set_term_width(width);
}
app

View File

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

View File

@ -12,7 +12,7 @@ impl Linter {
}
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 {

View File

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

View File

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

View File

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

View File

@ -62,6 +62,6 @@ mod tests {
#[test]
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 !self.force && path.exists() {
return Err(Error::OutputExists {
path: path.to_owned(),
});
return Err(Error::OutputExists { path: path.clone() });
}
}
@ -1151,7 +1149,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}
#[test]
@ -1182,7 +1180,7 @@ mod tests {
length: Bytes(4),
md5sum: None,
}
)
);
}
#[test]
@ -1213,7 +1211,7 @@ mod tests {
length: Bytes(4),
md5sum: None,
}
)
);
}
#[test]
@ -1258,7 +1256,7 @@ mod tests {
},
],
}
)
);
}
#[test]
@ -1285,7 +1283,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}
#[test]
@ -1319,7 +1317,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}
#[test]
@ -1346,7 +1344,7 @@ mod tests {
length: Bytes(0),
md5sum: None,
}
)
);
}
#[test]
@ -1367,7 +1365,7 @@ mod tests {
env.assert_ok();
let metainfo = env.load_metainfo("foo.torrent");
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]

View File

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

View File

@ -177,7 +177,7 @@ impl TorrentSummary {
fn torrent_summary_data(&self) -> TorrentSummaryJson {
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 } => (
files.len(),
files
@ -197,7 +197,7 @@ impl TorrentSummary {
};
TorrentSummaryJson {
name: self.metainfo.info.name.to_owned(),
name: self.metainfo.info.name.clone(),
comment: self.metainfo.comment.clone(),
creation_date: self.metainfo.creation_date,
created_by: self.metainfo.created_by.clone(),