Merge pull request #6 from rustic-rs/more-lints

Add more lints
This commit is contained in:
aawsome 2022-06-08 20:19:25 +02:00 committed by GitHub
commit dff0293f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View File

@ -118,7 +118,7 @@ impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
while !path.starts_with(&self.path) {
// save tree and go back to parent dir
let mut chunk = self.tree.serialize()?;
chunk.push('\n' as u8); // for whatever reason, restic adds a newline, so to be compatible...
chunk.push(b'\n'); // for whatever reason, restic adds a newline, so to be compatible...
let id = hash(&chunk);
let (mut node, tree, parent) = self

View File

@ -143,7 +143,7 @@ impl ReadSource for LocalSource {
impl Iterator for LocalSource {
type Item = Result<(PathBuf, Node)>;
fn next(&mut self) -> std::option::Option<Self::Item> {
fn next(&mut self) -> Option<Self::Item> {
self.walker
.next()
.map(|e| map_entry(e?, self.with_atime, &self.cache))

View File

@ -1,3 +1,33 @@
// TODO: add
// missing_docs,
// unused_results,
// trivial_casts??
#![warn(
bad_style,
const_err,
dead_code,
improper_ctypes,
missing_copy_implementations,
missing_debug_implementations,
non_shorthand_field_patterns,
no_mangle_generic_items,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
trivial_numeric_casts,
unsafe_code,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unconditional_recursion,
unused,
unused_allocation,
unused_comparisons,
unused_parens,
while_true
)]
use anyhow::Result;
mod archiver;

View File

@ -57,10 +57,7 @@ pub enum DeleteOption {
impl DeleteOption {
fn is_not_set(&self) -> bool {
match self {
Self::NotSet => true,
_ => false,
}
matches!(self, Self::NotSet)
}
}
@ -280,10 +277,7 @@ impl SnapshotFile {
/// Returns whether a snapshot must be deleted now
pub fn must_delete(&self, now: DateTime<Local>) -> bool {
match self.delete {
DeleteOption::After(time) if time < now => true,
_ => false,
}
matches!(self.delete,DeleteOption::After(time) if time < now)
}
/// Returns whether a snapshot must be kept now
@ -304,12 +298,12 @@ impl PartialEq<SnapshotFile> for SnapshotFile {
impl Eq for SnapshotFile {}
impl PartialOrd for SnapshotFile {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.time.partial_cmp(&other.time)
}
}
impl Ord for SnapshotFile {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
fn cmp(&self, other: &Self) -> Ordering {
self.time.cmp(&other.time)
}
}