diff --git a/Cargo.toml b/Cargo.toml index 56acfff..3a283b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "interlock" version = "0.0.0" authors = ["yvt "] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" readme = "README.md" description = "Readers-writer locks optimized for interval locks" categories = ["no-std"] @@ -17,7 +17,6 @@ std = [ ] [dependencies] -guard = "0.5.1" # polyfill futures = { version = "0.3.16", default-features = false } pin-utils = "0.1.0" pin-project = "1.0.8" diff --git a/rust-toolchain b/rust-toolchain index 726bdb6..0af5c96 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2021-08-29 +nightly-2021-09-04 diff --git a/src/core/rbtree.rs b/src/core/rbtree.rs index 744f8bd..0f4a746 100644 --- a/src/core/rbtree.rs +++ b/src/core/rbtree.rs @@ -8,7 +8,6 @@ use core::{ pin::Pin, ptr::NonNull, }; -use guard::guard; use super::{IntervalRwLockCore, LockCallback, UnlockCallback}; use crate::utils::{ @@ -908,8 +907,8 @@ where // `Option<[NonNull; 2]>`. If the result is `None`, return early. // // Safety: `*read_nodes` is safe to borrow - guard!(let Some(mut read_nodes) = unsafe { option_array2_as_ptr(read_nodes_ptr) } - else { return; }); + let Some(mut read_nodes) =( unsafe { option_array2_as_ptr(read_nodes_ptr) }) + else { return; }; // The range we are about to unlock // Safety: It's still safe to borrow @@ -1014,7 +1013,8 @@ where // If the result is `None`, return early. // // Safety: `*pending_node` is safe to borrow - guard!(let Some(mut write_node) = unsafe { option_as_ptr(write_node_ptr) } else { return; }); + let Some(mut write_node) = (unsafe { option_as_ptr(write_node_ptr) }) + else { return; }; let Range { start, mut end } = unsafe { write_node.as_ref().element.clone() }; diff --git a/src/lib.rs b/src/lib.rs index 7bb9b50..751e255 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![doc = include_str!("../README.md")] #![no_std] #![deny(unsafe_op_in_unsafe_fn)] +#![allow(clippy::needless_return)] // #![feature(const_fn_trait_bound)] #![feature(array_methods)] #![feature(never_type)] @@ -8,6 +9,7 @@ #![feature(const_impl_trait)] #![feature(slice_ptr_len)] #![feature(slice_ptr_get)] +#![feature(let_else)] // #[cfg(test)] extern crate std; diff --git a/src/raw/local.rs b/src/raw/local.rs index f9a43a2..90419f6 100644 --- a/src/raw/local.rs +++ b/src/raw/local.rs @@ -1,6 +1,5 @@ //! The thread-unsafe (but faster) implementation. use core::{ops::Range, pin::Pin}; -use guard::guard; use pin_cell::PinCell; use crate::{ @@ -27,11 +26,11 @@ fn deadlocked() -> ! { } macro_rules! borrow_core { - (let $p:pat = $self:ident.core) => { - guard!(let Ok(mut core) = $self.project_ref().core.try_borrow_mut() - else { core_is_not_reentrant(); }); - let $p = pin_cell::PinMut::as_mut(&mut core); - }; + (let $p:pat = $self:ident.core) => { + let Ok(mut core) = $self.project_ref().core.try_borrow_mut() + else { core_is_not_reentrant(); }; + let $p = pin_cell::PinMut::as_mut(&mut core); + }; } unsafe impl> RawIntervalRwLock diff --git a/src/utils/rbtree.rs b/src/utils/rbtree.rs index 3cecc0a..dea0fc9 100644 --- a/src/utils/rbtree.rs +++ b/src/utils/rbtree.rs @@ -16,7 +16,6 @@ use core::{ mem::{replace, swap}, ptr::NonNull, }; -use guard::guard; #[cfg(not(debug_assertions))] use core::hint::unreachable_unchecked; @@ -405,7 +404,7 @@ impl Node { // If `parent` is `None`, the black height change propagated up to // the root - guard!(let Some(mut parent) = node.as_ref().parent else { return; }); + let Some(mut parent) = node.as_ref().parent else { return; }; loop { // parent