Skip to content

Commit

Permalink
Fix additional clippy warnings
Browse files Browse the repository at this point in the history
This commit fixes a few Clippy warnings that are set to `deny` and
therefore cause CI checks in pull requests to fail.

I verified that `cargo clippy --all-targets --all-features` succeeds
(with no warnings nor errors) after the fixes.
  • Loading branch information
lukenels committed Nov 28, 2024
1 parent 02766ee commit 5575d61
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/annotations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cfg_if::cfg_if! {
use std::thread_local;

thread_local! {
static ANNOTATION_STATE: RefCell<Option<AnnotationState>> = RefCell::new(None);
static ANNOTATION_STATE: RefCell<Option<AnnotationState>> = const { RefCell::new(None) };
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
Expand Down Expand Up @@ -284,9 +284,11 @@ cfg_if::cfg_if! {
ANNOTATION_STATE.with(|cell| {
let mut bw = cell.borrow_mut();
assert!(bw.is_none(), "annotations already started");
let mut state: AnnotationState = Default::default();
state.version = ANNOTATION_VERSION;
state.last_task_id = Some(0.into());
let state = AnnotationState {
version: ANNOTATION_VERSION,
last_task_id: Some(0.into()),
..Default::default()
};
*bw = Some(state);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/sync/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ pub struct IntoIter<T> {
rx: Receiver<T>,
}

impl<'a, T> Iterator for Iter<'a, T> {
impl<T> Iterator for Iter<'_, T> {
type Item = T;

fn next(&mut self) -> Option<T> {
self.rx.recv().ok()
}
}

impl<'a, T> Iterator for TryIter<'a, T> {
impl<T> Iterator for TryIter<'_, T> {
type Item = T;

fn next(&mut self) -> Option<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
}
}

impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
fn drop(&mut self) {
// Release the inner mutex
self.inner = None;
Expand Down
8 changes: 4 additions & 4 deletions tests/demo/bounded_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! This file implements the example from a blog post about Coyote (P#):
//! https://cloudblogs.microsoft.com/opensource/2020/07/14/extreme-programming-meets-systematic-testing-using-coyote/
//! The comments in this file are quotes from that blog post.
// For symmetry we clone some `Arc`s even though we could just move them
#![allow(clippy::redundant_clone)]

Expand All @@ -8,10 +12,6 @@ use shuttle::{check_random, replay, thread};
use std::sync::Arc;
use test_log::test;

/// This file implements the example from a blog post about Coyote (P#):
/// https://cloudblogs.microsoft.com/opensource/2020/07/14/extreme-programming-meets-systematic-testing-using-coyote/
/// The comments in this file are quotes from that blog post.
/// Let’s walk through how Coyote can easily solve the programming problem posed by Tom Cargill. He
/// shared a BoundedBuffer implementation written in Java with a known, but tricky, deadlock bug.
///
Expand Down

0 comments on commit 5575d61

Please sign in to comment.