Skip to content

Commit 9744bc1

Browse files
committed
Fix errir when lender is not used
1 parent 3eee309 commit 9744bc1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl core::fmt::Display for PointerError {
3030
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3131
match self {
3232
Self::Null => write!(f, "dereference a null pointer will produce a crash"),
33+
#[cfg(all(feature = "std", feature = "lender"))]
3334
Self::Invalid => write!(f, "dereference a unknown pointer could produce a crash"),
3435
#[cfg(all(feature = "std", feature = "lender"))]
3536
Self::InvalidType => write!(

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub fn raw<T: 'static>(data: T) -> Result<*mut T, PointerError> {
6363
#[allow(clippy::not_unsafe_ptr_arg_deref)]
6464
pub unsafe fn own_back<T: 'static>(pointer: *mut T) -> Result<T, PointerError> {
6565
validation::not_null_pointer(pointer)?;
66+
#[cfg(all(feature = "std", feature = "lender"))]
6667
validation::lent_pointer(pointer)?;
6768
let boxed = { Box::from_raw(pointer) };
6869

src/validation.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ pub fn not_null_pointer<T>(pointer: *const T) -> Result<(), PointerError> {
1313
}
1414

1515
#[inline]
16+
#[cfg(all(feature = "std", feature = "lender"))]
1617
pub fn lent_pointer<T: 'static>(pointer: *const T) -> Result<(), PointerError> {
17-
#[cfg(not(all(feature = "std", feature = "lender")))]
18-
return Ok(());
19-
#[cfg(all(feature = "std", feature = "lender"))]
2018
match lender::lent_type_of(pointer) {
2119
Some(type_id) if type_id != std::any::TypeId::of::<T>() => {
2220
log::error!(

0 commit comments

Comments
 (0)