diff --git a/foyer-common/src/code.rs b/foyer-common/src/code.rs index 6e127119..94ee3ec4 100644 --- a/foyer-common/src/code.rs +++ b/foyer-common/src/code.rs @@ -20,7 +20,7 @@ use paste::paste; pub type CodingError = anyhow::Error; pub type CodingResult = Result; -trait BufExt: Buf { +pub trait BufExt: Buf { cfg_match! { cfg(target_pointer_width = "16") => { fn get_usize(&mut self) -> usize { @@ -54,7 +54,7 @@ trait BufExt: Buf { impl BufExt for T {} -trait BufMutExt: BufMut { +pub trait BufMutExt: BufMut { cfg_match! { cfg(target_pointer_width = "16") => { fn put_usize(&mut self, v: usize) { diff --git a/foyer-common/src/lib.rs b/foyer-common/src/lib.rs index 46e94ee4..af387881 100644 --- a/foyer-common/src/lib.rs +++ b/foyer-common/src/lib.rs @@ -14,10 +14,8 @@ #![feature(trait_alias)] #![feature(lint_reasons)] -#![feature(bound_map)] #![feature(associated_type_defaults)] #![feature(cfg_match)] -#![feature(let_chains)] #![cfg_attr(coverage_nightly, feature(coverage_attribute))] pub mod async_queue; diff --git a/foyer-experimental/src/notify.rs b/foyer-experimental/src/notify.rs index e98a409e..c03b4679 100644 --- a/foyer-experimental/src/notify.rs +++ b/foyer-experimental/src/notify.rs @@ -71,7 +71,6 @@ impl Notified { #[cfg(test)] mod tests { use std::{ - sync::Arc, thread::{sleep, spawn}, time::Duration, }; diff --git a/foyer-experimental/src/wal.rs b/foyer-experimental/src/wal.rs index 517e63b6..2df7b76d 100644 --- a/foyer-experimental/src/wal.rs +++ b/foyer-experimental/src/wal.rs @@ -147,7 +147,12 @@ impl TombstoneLog { path.push(format!("tombstone-{:08X}", config.id)); - let file = OpenOptions::new().write(true).read(true).create(true).open(path)?; + let file = OpenOptions::new() + .write(true) + .read(true) + .truncate(true) + .create(true) + .open(path)?; let inner = Arc::new(TombstoneLogInner { inflights: Mutex::new(vec![]), diff --git a/foyer-intrusive/src/collections/dlist.rs b/foyer-intrusive/src/collections/dlist.rs index 2712808d..f4329fa6 100644 --- a/foyer-intrusive/src/collections/dlist.rs +++ b/foyer-intrusive/src/collections/dlist.rs @@ -76,6 +76,15 @@ where } } +impl Default for Dlist +where + A: Adapter, +{ + fn default() -> Self { + Self::new() + } +} + impl Dlist where A: Adapter, diff --git a/foyer-intrusive/src/core/adapter.rs b/foyer-intrusive/src/core/adapter.rs index 3f98d74e..691bf8a6 100644 --- a/foyer-intrusive/src/core/adapter.rs +++ b/foyer-intrusive/src/core/adapter.rs @@ -117,8 +117,6 @@ pub unsafe trait PriorityAdapter: Adapter { /// # Examples /// /// ``` -/// #![feature(offset_of)] -/// /// use foyer_intrusive::{intrusive_adapter, key_adapter}; /// use foyer_intrusive::core::adapter::{Adapter, KeyAdapter, Link}; /// use foyer_intrusive::core::pointer::Pointer; @@ -215,8 +213,6 @@ macro_rules! intrusive_adapter { /// # Examples /// /// ``` -/// #![feature(offset_of)] -/// /// use foyer_intrusive::{intrusive_adapter, key_adapter}; /// use foyer_intrusive::core::adapter::{Adapter, KeyAdapter, Link}; /// use foyer_intrusive::core::pointer::Pointer; @@ -286,8 +282,6 @@ macro_rules! key_adapter { /// # Examples /// /// ``` -/// #![feature(offset_of)] -/// /// use foyer_intrusive::{intrusive_adapter, priority_adapter}; /// use foyer_intrusive::core::adapter::{Adapter, PriorityAdapter, Link}; /// use foyer_intrusive::core::pointer::Pointer; @@ -343,7 +337,7 @@ mod tests { use itertools::Itertools; use super::*; - use crate::{collections::dlist::*, intrusive_adapter}; + use crate::collections::dlist::*; #[derive(Debug)] struct DlistItem { diff --git a/foyer-intrusive/src/core/pointer.rs b/foyer-intrusive/src/core/pointer.rs index 7bac29f2..2c23b642 100644 --- a/foyer-intrusive/src/core/pointer.rs +++ b/foyer-intrusive/src/core/pointer.rs @@ -240,7 +240,8 @@ unsafe impl DowngradablePointerOps for Arc { #[cfg(test)] mod tests { - use std::{boxed::Box, fmt::Debug, mem, pin::Pin, rc::Rc, sync::Arc}; + + use std::mem::transmute; use super::*; @@ -319,14 +320,14 @@ mod tests { unsafe { let p = Box::new(1) as Box; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Box = as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } @@ -335,14 +336,14 @@ mod tests { unsafe { let p = Rc::new(1) as Rc; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Rc = as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } @@ -351,14 +352,14 @@ mod tests { unsafe { let p = Arc::new(1) as Arc; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Arc = as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } @@ -426,14 +427,14 @@ mod tests { unsafe { let p = Pin::new(Box::new(1)) as Pin>; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Pin> = > as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } @@ -442,14 +443,14 @@ mod tests { unsafe { let p = Pin::new(Rc::new(1)) as Pin>; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Pin> = > as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } @@ -458,14 +459,14 @@ mod tests { unsafe { let p = Pin::new(Arc::new(1)) as Pin>; let a: *const dyn Debug = &*p; - let b: (usize, usize) = mem::transmute(a); + let b: (usize, usize) = transmute(a); let r = p.into_ptr(); assert_eq!(a, r); - assert_eq!(b, mem::transmute(r)); + assert_eq!(b, transmute(r)); let p2: Pin> = > as Pointer>::from_ptr(r); let a2: *const dyn Debug = &*p2; assert_eq!(a, a2); - assert_eq!(b, mem::transmute(a2)); + assert_eq!(b, transmute(a2)); } } diff --git a/foyer-intrusive/src/eviction/sfifo.rs b/foyer-intrusive/src/eviction/sfifo.rs index 483c882b..4fdd7cc2 100644 --- a/foyer-intrusive/src/eviction/sfifo.rs +++ b/foyer-intrusive/src/eviction/sfifo.rs @@ -375,8 +375,6 @@ where mod tests { use std::sync::Arc; - use itertools::Itertools; - use super::*; use crate::{eviction::EvictionPolicyExt, priority_adapter}; diff --git a/foyer-intrusive/src/lib.rs b/foyer-intrusive/src/lib.rs index 4241d821..0164576b 100644 --- a/foyer-intrusive/src/lib.rs +++ b/foyer-intrusive/src/lib.rs @@ -13,11 +13,8 @@ // limitations under the License. #![feature(associated_type_bounds)] -#![feature(ptr_metadata)] #![feature(trait_alias)] #![feature(lint_reasons)] -#![feature(offset_of)] -#![expect(clippy::new_without_default)] pub use memoffset::offset_of; @@ -27,8 +24,6 @@ pub use memoffset::offset_of; /// # Examples /// /// ``` -/// #![feature(offset_of)] -/// /// use foyer_intrusive::container_of; /// /// struct S { x: u32, y: u32 }; diff --git a/foyer-memory/src/lib.rs b/foyer-memory/src/lib.rs index cc504e32..73a26ebe 100644 --- a/foyer-memory/src/lib.rs +++ b/foyer-memory/src/lib.rs @@ -66,7 +66,6 @@ //! destroyed. #![feature(trait_alias)] -#![feature(offset_of)] pub trait Key: Send + Sync + 'static + std::hash::Hash + Eq + Ord {} pub trait Value: Send + Sync + 'static {} diff --git a/foyer-storage/src/buffer.rs b/foyer-storage/src/buffer.rs index dfc0c179..1db7cbea 100644 --- a/foyer-storage/src/buffer.rs +++ b/foyer-storage/src/buffer.rs @@ -349,7 +349,7 @@ mod tests { let res = buffer.write(entry).await; let entry = match res { - Err(BufferError::NeedRotate(entry)) => Box::into_inner(entry), + Err(BufferError::NeedRotate(entry)) => *entry, _ => panic!("should be not enough error"), }; @@ -396,7 +396,7 @@ mod tests { let res = buffer.write(entry).await; let entry = match res { - Err(BufferError::NeedRotate(entry)) => Box::into_inner(entry), + Err(BufferError::NeedRotate(entry)) => *entry, _ => panic!("should be not enough error"), }; diff --git a/foyer-storage/src/device/allocator.rs b/foyer-storage/src/device/allocator.rs index c848417b..3919334c 100644 --- a/foyer-storage/src/device/allocator.rs +++ b/foyer-storage/src/device/allocator.rs @@ -52,14 +52,14 @@ mod tests { let allocator = AlignedAllocator::new(ALIGN); let mut buf: Vec = Vec::with_capacity_in(ALIGN * 8, &allocator); - bits::assert_aligned(ALIGN, buf.as_ptr().addr()); + bits::assert_aligned(ALIGN, buf.as_ptr() as _); buf.extend_from_slice(&[b'x'; ALIGN * 8]); - bits::assert_aligned(ALIGN, buf.as_ptr().addr()); + bits::assert_aligned(ALIGN, buf.as_ptr() as _); assert_eq!(buf, [b'x'; ALIGN * 8]); buf.extend_from_slice(&[b'x'; ALIGN * 8]); - bits::assert_aligned(ALIGN, buf.as_ptr().addr()); + bits::assert_aligned(ALIGN, buf.as_ptr() as _); assert_eq!(buf, [b'x'; ALIGN * 16]) } } diff --git a/foyer-storage/src/flusher.rs b/foyer-storage/src/flusher.rs index 6b19a329..84697268 100644 --- a/foyer-storage/src/flusher.rs +++ b/foyer-storage/src/flusher.rs @@ -144,7 +144,7 @@ where let old_region = self.buffer.region(); let entry = match self.buffer.write(entry).await { - Err(BufferError::NeedRotate(entry)) => Box::into_inner(entry), + Err(BufferError::NeedRotate(entry)) => *entry, Ok(entries) => return self.update_catalog(entries).await, Err(e) => return Err(e.into()), }; diff --git a/foyer-storage/src/lazy.rs b/foyer-storage/src/lazy.rs index a93f8542..295032d7 100644 --- a/foyer-storage/src/lazy.rs +++ b/foyer-storage/src/lazy.rs @@ -230,11 +230,7 @@ mod tests { use foyer_intrusive::eviction::fifo::FifoConfig; use super::*; - use crate::{ - device::fs::FsDeviceConfig, - storage::StorageExt, - store::{FifoFsStoreConfig, Store}, - }; + use crate::{device::fs::FsDeviceConfig, storage::StorageExt, store::FifoFsStoreConfig}; const KB: usize = 1024; const MB: usize = 1024 * 1024; diff --git a/foyer-storage/src/lib.rs b/foyer-storage/src/lib.rs index d9e98496..8d3e0647 100644 --- a/foyer-storage/src/lib.rs +++ b/foyer-storage/src/lib.rs @@ -13,17 +13,12 @@ // limitations under the License. #![feature(allocator_api)] -#![feature(strict_provenance)] #![feature(trait_alias)] -#![feature(get_mut_unchecked)] #![feature(let_chains)] #![feature(error_generic_member_access)] #![feature(lazy_cell)] #![feature(lint_reasons)] #![feature(associated_type_defaults)] -#![feature(box_into_inner)] -#![feature(try_trait_v2)] -#![feature(offset_of)] pub mod admission; pub mod buffer; diff --git a/foyer-storage/src/storage.rs b/foyer-storage/src/storage.rs index 3909731a..5d7f2d0b 100644 --- a/foyer-storage/src/storage.rs +++ b/foyer-storage/src/storage.rs @@ -314,7 +314,6 @@ impl ForceStorageExt for S where S: Storage {} #[cfg(test)] mod tests { - //! storage interface test use std::{path::Path, sync::Arc, time::Duration}; diff --git a/foyer/src/lib.rs b/foyer/src/lib.rs index 191d0932..32d97e4d 100644 --- a/foyer/src/lib.rs +++ b/foyer/src/lib.rs @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(trait_alias)] -#![feature(pattern)] - pub use foyer_common as common; pub use foyer_intrusive as intrusive; pub use foyer_memory as memory; diff --git a/rust-toolchain b/rust-toolchain index ef0ed508..2adf86df 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-12-26" \ No newline at end of file +channel = "nightly-2024-03-17" \ No newline at end of file