chore: clean relative to references and borrows

- lint message: the borrowed expression implements the required traits
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_borrows_for_generic_args
- lint message: this expression creates a reference which is immediately dereferenced by the compiler
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_borrow
- lint message: you don't need to add `&` to all patterns
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#match_ref_pat
- remove useless taken reference
lint message: needlessly taken reference of left operand
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#op_ref
- use &Path instead of &PathBuf as fn parameters
lint message: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#ptr_arg
This commit is contained in:
Gwen Lg
2025-12-13 17:43:05 +01:00
parent 209263eb93
commit 141b3f24f1
35 changed files with 129 additions and 134 deletions
+4 -5
View File
@@ -262,7 +262,7 @@ impl DataLayout {
pub(crate) fn primary_block_dir(&self, hash: &Hash) -> PathBuf {
let ipart = self.partition_from(hash);
let idir = self.part_prim[ipart] as usize;
self.block_dir_from(hash, &self.data_dirs[idir].path)
self.block_dir_from(hash, self.data_dirs[idir].path.clone())
}
pub(crate) fn secondary_block_dirs<'a>(
@@ -272,7 +272,7 @@ impl DataLayout {
let ipart = self.partition_from(hash);
self.part_sec[ipart]
.iter()
.map(move |idir| self.block_dir_from(hash, &self.data_dirs[*idir as usize].path))
.map(move |idir| self.block_dir_from(hash, self.data_dirs[*idir as usize].path.clone()))
}
fn partition_from(&self, hash: &Hash) -> usize {
@@ -283,8 +283,7 @@ impl DataLayout {
% DRIVE_NPART
}
fn block_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf {
let mut path = dir.clone();
fn block_dir_from(&self, hash: &Hash, mut path: PathBuf) -> PathBuf {
path.push(hex::encode(&hash.as_slice()[0..1]));
path.push(hex::encode(&hash.as_slice()[1..2]));
path
@@ -359,7 +358,7 @@ fn make_data_dirs(dirs: &DataDirEnum) -> Result<Vec<DataDir>, Error> {
}
fn dir_not_empty(path: &PathBuf) -> Result<bool, Error> {
for entry in std::fs::read_dir(&path)? {
for entry in std::fs::read_dir(path)? {
let dir = entry?;
let ft = dir.file_type()?;
let name = dir.file_name().into_string().ok();
+1 -1
View File
@@ -89,7 +89,7 @@ impl BlockRc {
.transaction(|tx| {
let mut cnt = 0;
for f in recalc_fns.iter() {
cnt += f(&tx, hash)?;
cnt += f(tx, hash)?;
}
let old_rc = RcEntry::parse_opt(tx.get(&self.rc_table, hash)?);
trace!(
+1 -1
View File
@@ -466,7 +466,7 @@ impl BlockResyncManager {
// First, check whether we are still supposed to store that
// block in the latest cluster layout version.
let storage_nodes = manager.storage_nodes_of(&hash)?;
let storage_nodes = manager.storage_nodes_of(hash)?;
if !storage_nodes.contains(&manager.system.id) {
info!(