diff --git a/clippy.toml b/clippy.toml index 8622df3..a0f7d24 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,2 @@ -msrv = "1.56.1" +msrv = "1.65.0" disallowed-types = ["std::collections::HashMap"] diff --git a/src/meta.rs b/src/meta.rs index a0a774a..a7059c9 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -64,6 +64,7 @@ where { type Item = AtomicRef<'a, T>; + #[allow(clippy::borrowed_box)] // variant of https://github.com/rust-lang/rust-clippy/issues/5770 fn next(&mut self) -> Option<::Item> { loop { let resource_id = match self.tys.get(self.index) { diff --git a/tests/meta_table_safety_113.rs b/tests/meta_table_safety_113.rs index bcb7cff..7be0b97 100644 --- a/tests/meta_table_safety_113.rs +++ b/tests/meta_table_safety_113.rs @@ -14,16 +14,17 @@ impl PointsToU64 for Box { struct MultipleData { _number: u64, - pointer: Box, + _pointer: Box, } unsafe impl CastFrom for dyn PointsToU64 { - fn cast(t: *mut MultipleData) -> *mut Self { - // note, this also assumes the pointer is non-null and probably other things which we can't - // assume in an implementation of `CastFrom`. - - // this is wrong and will cause a panic - unsafe { core::ptr::addr_of_mut!((*t).pointer) } + fn cast(_t: *mut MultipleData) -> *mut Self { + // This is wrong and will cause a panic + // + // NOTE: we use this instead of constructing a pointer to the field since + // there is no way to easily and safely do that currently! (this can be + // changed if offset_of macro is added to std). + core::ptr::NonNull::>::dangling().as_ptr() } } @@ -33,7 +34,7 @@ fn test_panics() { let mut table: MetaTable = MetaTable::new(); let md = MultipleData { _number: 0x0, // this will be casted to a pointer, then dereferenced - pointer: Box::new(42), + _pointer: Box::new(42), }; table.register::(); if let Some(t) = table.get(&md) {