fix clippy warnings

This commit is contained in:
Dustin J. Mitchell 2022-10-02 19:20:12 +00:00 committed by Tomas Babej
parent 7b35121374
commit 41625f8b11
5 changed files with 13 additions and 34 deletions

View file

@ -317,7 +317,7 @@ impl<'a> From<String> for RustString<'a> {
} }
} }
impl<'a> From<&str> for RustString<'static> { impl From<&str> for RustString<'static> {
fn from(string: &str) -> RustString<'static> { fn from(string: &str) -> RustString<'static> {
RustString::String(string.to_string()) RustString::String(string.to_string())
} }

View file

@ -276,14 +276,12 @@ where
let mut vec = unsafe { CL::take_val_from_arg(list, CL::null_value()) }; let mut vec = unsafe { CL::take_val_from_arg(list, CL::null_value()) };
// first, drop each of the elements in turn // first, drop each of the elements in turn
for e in vec.drain(..) { for e in vec.drain(..).flatten() {
if let Some(e) = e {
// SAFETY: // SAFETY:
// - e is a valid Element (promised by caller) // - e is a valid Element (promised by caller)
// - e is owned // - e is owned
drop(unsafe { PassByPointer::take_from_ptr_arg(e.as_ptr()) }); drop(unsafe { PassByPointer::take_from_ptr_arg(e.as_ptr()) });
} }
}
// then drop the vector // then drop the vector
drop(vec); drop(vec);
} }

View file

@ -271,7 +271,7 @@ mod test {
let unsealed = Unsealed { let unsealed = Unsealed {
version_id, version_id,
payload: payload, payload,
}; };
let sealed = cryptor.seal(unsealed).unwrap(); let sealed = cryptor.seal(unsealed).unwrap();
@ -291,7 +291,7 @@ mod test {
let unsealed = Unsealed { let unsealed = Unsealed {
version_id, version_id,
payload: payload, payload,
}; };
let mut sealed = cryptor.seal(unsealed).unwrap(); let mut sealed = cryptor.seal(unsealed).unwrap();
sealed.version_id = Uuid::new_v4(); // change the version_id sealed.version_id = Uuid::new_v4(); // change the version_id
@ -309,7 +309,7 @@ mod test {
let unsealed = Unsealed { let unsealed = Unsealed {
version_id, version_id,
payload: payload, payload,
}; };
let sealed = cryptor.seal(unsealed).unwrap(); let sealed = cryptor.seal(unsealed).unwrap();

View file

@ -173,10 +173,7 @@ impl TaskDb {
#[cfg(test)] #[cfg(test)]
pub(crate) fn operations(&mut self) -> Vec<ReplicaOp> { pub(crate) fn operations(&mut self) -> Vec<ReplicaOp> {
let mut txn = self.storage.txn().unwrap(); let mut txn = self.storage.txn().unwrap();
txn.operations() txn.operations().unwrap().to_vec()
.unwrap()
.iter().cloned()
.collect()
} }
} }

View file

@ -119,12 +119,7 @@ mod test {
assert_eq!( assert_eq!(
db.working_set()?, db.working_set()?,
vec![ vec![None, Some(uuids[1]), Some(uuids[3]), Some(uuids[4])]
None,
Some(uuids[1]),
Some(uuids[3]),
Some(uuids[4])
]
); );
rebuild( rebuild(
@ -142,22 +137,11 @@ mod test {
let exp = if renumber { let exp = if renumber {
// uuids[1] and uuids[4] are already in the working set, so are compressed // uuids[1] and uuids[4] are already in the working set, so are compressed
// to the top, and then uuids[0] is added. // to the top, and then uuids[0] is added.
vec![ vec![None, Some(uuids[1]), Some(uuids[4]), Some(uuids[0])]
None,
Some(uuids[1]),
Some(uuids[4]),
Some(uuids[0]),
]
} else { } else {
// uuids[1] and uuids[4] are already in the working set, at indexes 1 and 3, // uuids[1] and uuids[4] are already in the working set, at indexes 1 and 3,
// and then uuids[0] is added. // and then uuids[0] is added.
vec![ vec![None, Some(uuids[1]), None, Some(uuids[4]), Some(uuids[0])]
None,
Some(uuids[1]),
None,
Some(uuids[4]),
Some(uuids[0]),
]
}; };
assert_eq!(db.working_set()?, exp); assert_eq!(db.working_set()?, exp);