diff --git a/src/base/conversion.rs b/src/base/conversion.rs index e52a0c5d..30b68bb7 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -118,12 +118,11 @@ macro_rules! impl_from_into_asref_1D( S: ContiguousStorage { #[inline] fn into(self) -> [N; $SZ] { - unsafe { - let mut res: [N; $SZ] = mem::uninitialized(); - ptr::copy_nonoverlapping(self.data.ptr(), &mut res[0], $SZ); + let mut res = mem::MaybeUninit::<[N; $SZ]>::uninit(); - res - } + unsafe { ptr::copy_nonoverlapping(self.data.ptr(), res.as_mut_ptr() as *mut N, $SZ) }; + + unsafe { res.assume_init() } } } @@ -185,12 +184,11 @@ macro_rules! impl_from_into_asref_2D( where S: ContiguousStorage { #[inline] fn into(self) -> [[N; $SZRows]; $SZCols] { - unsafe { - let mut res: [[N; $SZRows]; $SZCols] = mem::uninitialized(); - ptr::copy_nonoverlapping(self.data.ptr(), &mut res[0][0], $SZRows * $SZCols); + let mut res = mem::MaybeUninit::<[[N; $SZRows]; $SZCols]>::uninit(); - res - } + unsafe { ptr::copy_nonoverlapping(self.data.ptr(), res.as_mut_ptr() as *mut N, $SZRows * $SZCols) }; + + unsafe { res.assume_init() } } } diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index c07c8708..cbfb5f61 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -46,7 +46,8 @@ where #[inline] unsafe fn allocate_uninitialized(_: R, _: C) -> Self::Buffer { - mem::uninitialized() + // TODO: Undefined behavior, see #556 + mem::MaybeUninit::::uninit().assume_init() } #[inline] diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 112996d3..e7150e65 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -190,7 +190,6 @@ pub trait DimName: Dim { type Value: NamedDim; /// The name of this dimension, i.e., the singleton `Self`. - #[inline] fn name() -> Self; // FIXME: this is not a very idiomatic name. diff --git a/src/base/storage.rs b/src/base/storage.rs index e7439552..8e472e1e 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -94,13 +94,11 @@ pub unsafe trait Storage: Debug + Sized { } /// Indicates whether this data buffer stores its elements contiguously. - #[inline] fn is_contiguous(&self) -> bool; /// Retrieves the data buffer as a contiguous slice. /// /// The matrix components may not be stored in a contiguous way, depending on the strides. - #[inline] fn as_slice(&self) -> &[N]; /// Builds a matrix data storage that does not contain any reference. @@ -166,7 +164,6 @@ pub unsafe trait StorageMut: Storage { /// Retrieves the mutable data buffer as a contiguous slice. /// /// Matrix components may not be contiguous, depending on its strides. - #[inline] fn as_mut_slice(&mut self) -> &mut [N]; } diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 6fad5e8c..4f61ce6e 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -7,9 +7,6 @@ use na::{ Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6, }; -use typenum::{UInt, UTerm}; -use serde_json::error::Category::Data; -use typenum::bit::{B0, B1}; #[test] fn iter() { diff --git a/tests/linalg/inverse.rs b/tests/linalg/inverse.rs index 61f43324..f0be4dd7 100644 --- a/tests/linalg/inverse.rs +++ b/tests/linalg/inverse.rs @@ -130,7 +130,7 @@ fn matrix5_try_inverse_scaled_identity() { 0.0, 1.0e+20, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0e+20, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0e+20, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0e+20);; + 0.0, 0.0, 0.0, 0.0, 1.0e+20); let a_inv = a.try_inverse().expect("Matrix should be invertible"); assert_relative_eq!(a_inv, expected_inverse);