From cddb2eeadc122f956bab6046b4f4221774e9e3ff Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 19 May 2024 15:57:33 +0200 Subject: [PATCH 1/2] Avoid legacy numeric constants. --- src/arrayformat.rs | 6 +++--- src/arraytraits.rs | 2 +- src/dimension/mod.rs | 3 +-- src/linalg/impl_linalg.rs | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/arrayformat.rs b/src/arrayformat.rs index 202805604..1a3b714c3 100644 --- a/src/arrayformat.rs +++ b/src/arrayformat.rs @@ -51,9 +51,9 @@ impl FormatOptions fn set_no_limit(mut self, no_limit: bool) -> Self { if no_limit { - self.axis_collapse_limit = std::usize::MAX; - self.axis_collapse_limit_next_last = std::usize::MAX; - self.axis_collapse_limit_last = std::usize::MAX; + self.axis_collapse_limit = usize::MAX; + self.axis_collapse_limit_next_last = usize::MAX; + self.axis_collapse_limit_last = usize::MAX; } self } diff --git a/src/arraytraits.rs b/src/arraytraits.rs index ea0b380ed..2f72cea2f 100644 --- a/src/arraytraits.rs +++ b/src/arraytraits.rs @@ -386,7 +386,7 @@ where Slice: AsMut<[A]> let xs = slice.as_mut(); if mem::size_of::() == 0 { assert!( - xs.len() <= ::std::isize::MAX as usize, + xs.len() <= isize::MAX as usize, "Slice length must fit in `isize`.", ); } diff --git a/src/dimension/mod.rs b/src/dimension/mod.rs index d11dd996b..6c5cd0e84 100644 --- a/src/dimension/mod.rs +++ b/src/dimension/mod.rs @@ -26,7 +26,6 @@ pub use self::remove_axis::RemoveAxis; pub(crate) use self::axes::axes_of; pub(crate) use self::reshape::reshape_dim; -use std::isize; use std::mem; #[macro_use] @@ -94,7 +93,7 @@ pub fn size_of_shape_checked(dim: &D) -> Result .filter(|&&d| d != 0) .try_fold(1usize, |acc, &d| acc.checked_mul(d)) .ok_or_else(|| from_kind(ErrorKind::Overflow))?; - if size_nonzero > ::std::isize::MAX as usize { + if size_nonzero > isize::MAX as usize { Err(from_kind(ErrorKind::Overflow)) } else { Ok(dim.size()) diff --git a/src/linalg/impl_linalg.rs b/src/linalg/impl_linalg.rs index bcfcba94e..6fb850b50 100644 --- a/src/linalg/impl_linalg.rs +++ b/src/linalg/impl_linalg.rs @@ -296,7 +296,7 @@ where fn dot_shape_error(m: usize, k: usize, k2: usize, n: usize) -> ! { match m.checked_mul(n) { - Some(len) if len <= ::std::isize::MAX as usize => {} + Some(len) if len <= isize::MAX as usize => {} _ => panic!("ndarray: shape {} × {} overflows isize", m, n), } panic!( From 778ee689f092b26e8f1145220a934c2c769ae32e Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 19 May 2024 16:10:18 +0200 Subject: [PATCH 2/2] Allow for rawpointer::PointerExt being unused as the inherent methods are stable on nightly. --- src/data_repr.rs | 1 + src/data_traits.rs | 1 + src/impl_constructors.rs | 1 + src/impl_methods.rs | 1 + src/impl_owned_array.rs | 1 + src/impl_views/conversions.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/src/data_repr.rs b/src/data_repr.rs index c64cbcfcf..a24cd7789 100644 --- a/src/data_repr.rs +++ b/src/data_repr.rs @@ -8,6 +8,7 @@ use std::mem; use std::mem::ManuallyDrop; use std::ptr::NonNull; +#[allow(unused_imports)] use rawpointer::PointerExt; /// Array's representation. diff --git a/src/data_traits.rs b/src/data_traits.rs index a2784b8d3..960c561da 100644 --- a/src/data_traits.rs +++ b/src/data_traits.rs @@ -8,6 +8,7 @@ //! The data (inner representation) traits for ndarray +#[allow(unused_imports)] use rawpointer::PointerExt; use alloc::sync::Arc; diff --git a/src/impl_constructors.rs b/src/impl_constructors.rs index e5f19a837..acd7f8167 100644 --- a/src/impl_constructors.rs +++ b/src/impl_constructors.rs @@ -34,6 +34,7 @@ use crate::iterators::TrustedIterator; use crate::StrideShape; #[cfg(feature = "std")] use crate::{geomspace, linspace, logspace}; +#[allow(unused_imports)] use rawpointer::PointerExt; /// # Constructor Methods for Owned Arrays diff --git a/src/impl_methods.rs b/src/impl_methods.rs index d1250ec28..f21b407e1 100644 --- a/src/impl_methods.rs +++ b/src/impl_methods.rs @@ -10,6 +10,7 @@ use alloc::slice; use alloc::vec; #[cfg(not(feature = "std"))] use alloc::vec::Vec; +#[allow(unused_imports)] use rawpointer::PointerExt; use std::mem::{size_of, ManuallyDrop}; diff --git a/src/impl_owned_array.rs b/src/impl_owned_array.rs index 393c2e075..e7bf6d3a1 100644 --- a/src/impl_owned_array.rs +++ b/src/impl_owned_array.rs @@ -3,6 +3,7 @@ use alloc::vec::Vec; use std::mem; use std::mem::MaybeUninit; +#[allow(unused_imports)] use rawpointer::PointerExt; use crate::imp_prelude::*; diff --git a/src/impl_views/conversions.rs b/src/impl_views/conversions.rs index 18f263691..ef6923a56 100644 --- a/src/impl_views/conversions.rs +++ b/src/impl_views/conversions.rs @@ -7,6 +7,7 @@ // except according to those terms. use alloc::slice; +#[allow(unused_imports)] use rawpointer::PointerExt; use std::mem::MaybeUninit;