fix some clippy warnings

This commit is contained in:
Dustin J. Mitchell 2022-02-09 02:59:01 +00:00
parent a270b6c254
commit f96b5415c8
3 changed files with 4 additions and 3 deletions

View file

@ -1,4 +1,5 @@
#![warn(unsafe_op_in_unsafe_fn)] #![warn(unsafe_op_in_unsafe_fn)]
#![warn(clippy::undocumented_unsafe_blocks)]
mod traits; mod traits;
mod util; mod util;

View file

@ -69,12 +69,12 @@ impl From<Replica> for TCReplica {
/// Utility function to allow using `?` notation to return an error value. This makes /// Utility function to allow using `?` notation to return an error value. This makes
/// a mutable borrow, because most Replica methods require a `&mut`. /// a mutable borrow, because most Replica methods require a `&mut`.
fn wrap<'a, T, F>(rep: *mut TCReplica, f: F, err_value: T) -> T fn wrap<T, F>(rep: *mut TCReplica, f: F, err_value: T) -> T
where where
F: FnOnce(&mut Replica) -> anyhow::Result<T>, F: FnOnce(&mut Replica) -> anyhow::Result<T>,
{ {
// SAFETY: see type docstring // SAFETY: see type docstring
let rep: &'a mut TCReplica = unsafe { TCReplica::from_arg_ref_mut(rep) }; let rep: &mut TCReplica = unsafe { TCReplica::from_arg_ref_mut(rep) };
if rep.mut_borrowed { if rep.mut_borrowed {
panic!("replica is borrowed and cannot be used"); panic!("replica is borrowed and cannot be used");
} }

View file

@ -10,5 +10,5 @@ pub(crate) fn vec_into_raw_parts<T>(vec: Vec<T>) -> (*mut T, usize, usize) {
// - disable dropping the Vec with ManuallyDrop // - disable dropping the Vec with ManuallyDrop
// - extract ptr, len, and capacity using those methods // - extract ptr, len, and capacity using those methods
let mut vec = std::mem::ManuallyDrop::new(vec); let mut vec = std::mem::ManuallyDrop::new(vec);
return (vec.as_mut_ptr(), vec.len(), vec.capacity()); (vec.as_mut_ptr(), vec.len(), vec.capacity())
} }