Skip to content

Commit

Permalink
Merge pull request #100 from GnomedDev/clippy
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
Manishearth authored Oct 14, 2024
2 parents c80cca4 + 3b66e09 commit 6c812ec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use core::ops::Deref;
use core::ptr::{self, NonNull};
use core::sync::atomic;
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
use core::{isize, usize};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -888,13 +887,13 @@ mod tests {
let mut uninit = Arc::new_uninit();
let clone = uninit.clone();

let x: &MaybeUninit<String> = &*clone;
let x: &MaybeUninit<String> = &clone;

// This write invalidates `x` reference
uninit.write(String::from("nonononono"));

// Read invalidated reference to trigger UB
let _ = &*x;
let _ = *x;
}

#[test]
Expand All @@ -904,13 +903,13 @@ mod tests {
let mut uninit = Arc::new_uninit_slice(13);
let clone = uninit.clone();

let x: &[MaybeUninit<String>] = &*clone;
let x: &[MaybeUninit<String>] = &clone;

// This write invalidates `x` reference
uninit.as_mut_slice()[0].write(String::from("nonononono"));

// Read invalidated reference to trigger UB
let _ = &*x;
let _ = *x;
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/arc_union.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::fmt;
use core::marker::PhantomData;
use core::ptr;
use core::usize;

use super::{Arc, ArcBorrow};

Expand Down
3 changes: 0 additions & 3 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use core::iter::{ExactSizeIterator, Iterator};
use core::marker::PhantomData;
use core::mem::{self, ManuallyDrop};
use core::ptr::{self, addr_of_mut};
use core::usize;

use super::{Arc, ArcInner};

Expand Down Expand Up @@ -344,7 +343,6 @@ mod tests {
);

let empty = Arc::from_header_and_str((), "");
assert_eq!(empty.header, ());
assert_eq!(&empty.slice, "");
}

Expand All @@ -358,7 +356,6 @@ mod tests {
let c: Arc<HeaderSlice<(), [u32]>> = b.into();

assert_eq!(&c.slice, [12, 17, 16]);
assert_eq!(c.header, ());
}

#[test]
Expand Down
5 changes: 2 additions & 3 deletions src/thin_arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use core::marker::PhantomData;
use core::mem::ManuallyDrop;
use core::ops::Deref;
use core::ptr;
use core::usize;

use super::{Arc, ArcInner, HeaderSliceWithLength, HeaderWithLength};

Expand Down Expand Up @@ -167,7 +166,7 @@ impl<H, T> ThinArc<H, T> {
/// however `triomphe::Arc` does not support weak references.
#[inline]
pub fn strong_count(this: &Self) -> usize {
Self::with_arc(this, |arc| Arc::strong_count(arc))
Self::with_arc(this, Arc::strong_count)
}
}

Expand Down Expand Up @@ -485,7 +484,7 @@ mod tests {
arc.clone(),
arc.clone(),
];
arc.with_arc(|arc| assert_eq!(6, Arc::count(&arc)));
arc.with_arc(|arc| assert_eq!(6, Arc::count(arc)));

// If the layout is not compatible, then the data might be corrupted.
assert_eq!(arc.header.header, 1);
Expand Down

0 comments on commit 6c812ec

Please sign in to comment.