Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two instances of elided_named_lifetimes warning #165

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion src/lazy_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<T: Sync> std::fmt::Debug for Lazy<T> {

impl<T: Sync> Lazy<T> {
/// Get a reference to the lazy value, initializing it first if necessary.
pub fn get(&'static self) -> &T {
pub fn get(&'static self) -> &'static T {
// Safety: see the usage below
unsafe fn extend_lt<T>(t: &T) -> &'static T {
std::mem::transmute(t)
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
2 changes: 1 addition & 1 deletion src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<T: 'static> LocalKey<T> {
Ok(f(value))
}

fn get(&'static self) -> Option<std::result::Result<&T, AccessError>> {
fn get(&'static self) -> Option<std::result::Result<&'static T, AccessError>> {
// Safety: see the usage below
unsafe fn extend_lt<'b, T>(t: &'_ T) -> &'b T {
std::mem::transmute(t)
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