Merge pull request #705 from ProfFan/fix/warnings

Fix warnings on latest rustc
This commit is contained in:
Sébastien Crozet 2020-04-01 08:33:50 +02:00 committed by GitHub
commit fee5b41dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 19 deletions

View File

@ -118,12 +118,11 @@ macro_rules! impl_from_into_asref_1D(
S: ContiguousStorage<N, $NRows, $NCols> { S: ContiguousStorage<N, $NRows, $NCols> {
#[inline] #[inline]
fn into(self) -> [N; $SZ] { fn into(self) -> [N; $SZ] {
unsafe { let mut res = mem::MaybeUninit::<[N; $SZ]>::uninit();
let mut res: [N; $SZ] = mem::uninitialized();
ptr::copy_nonoverlapping(self.data.ptr(), &mut res[0], $SZ);
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<N, $NRows, $NCols> { where S: ContiguousStorage<N, $NRows, $NCols> {
#[inline] #[inline]
fn into(self) -> [[N; $SZRows]; $SZCols] { fn into(self) -> [[N; $SZRows]; $SZCols] {
unsafe { let mut res = mem::MaybeUninit::<[[N; $SZRows]; $SZCols]>::uninit();
let mut res: [[N; $SZRows]; $SZCols] = mem::uninitialized();
ptr::copy_nonoverlapping(self.data.ptr(), &mut res[0][0], $SZRows * $SZCols);
res unsafe { ptr::copy_nonoverlapping(self.data.ptr(), res.as_mut_ptr() as *mut N, $SZRows * $SZCols) };
}
unsafe { res.assume_init() }
} }
} }

View File

@ -46,7 +46,8 @@ where
#[inline] #[inline]
unsafe fn allocate_uninitialized(_: R, _: C) -> Self::Buffer { unsafe fn allocate_uninitialized(_: R, _: C) -> Self::Buffer {
mem::uninitialized() // TODO: Undefined behavior, see #556
mem::MaybeUninit::<Self::Buffer>::uninit().assume_init()
} }
#[inline] #[inline]

View File

@ -190,7 +190,6 @@ pub trait DimName: Dim {
type Value: NamedDim<Name = Self>; type Value: NamedDim<Name = Self>;
/// The name of this dimension, i.e., the singleton `Self`. /// The name of this dimension, i.e., the singleton `Self`.
#[inline]
fn name() -> Self; fn name() -> Self;
// FIXME: this is not a very idiomatic name. // FIXME: this is not a very idiomatic name.

View File

@ -94,13 +94,11 @@ pub unsafe trait Storage<N: Scalar, R: Dim, C: Dim = U1>: Debug + Sized {
} }
/// Indicates whether this data buffer stores its elements contiguously. /// Indicates whether this data buffer stores its elements contiguously.
#[inline]
fn is_contiguous(&self) -> bool; fn is_contiguous(&self) -> bool;
/// Retrieves the data buffer as a contiguous slice. /// Retrieves the data buffer as a contiguous slice.
/// ///
/// The matrix components may not be stored in a contiguous way, depending on the strides. /// The matrix components may not be stored in a contiguous way, depending on the strides.
#[inline]
fn as_slice(&self) -> &[N]; fn as_slice(&self) -> &[N];
/// Builds a matrix data storage that does not contain any reference. /// Builds a matrix data storage that does not contain any reference.
@ -166,7 +164,6 @@ pub unsafe trait StorageMut<N: Scalar, R: Dim, C: Dim = U1>: Storage<N, R, C> {
/// Retrieves the mutable data buffer as a contiguous slice. /// Retrieves the mutable data buffer as a contiguous slice.
/// ///
/// Matrix components may not be contiguous, depending on its strides. /// Matrix components may not be contiguous, depending on its strides.
#[inline]
fn as_mut_slice(&mut self) -> &mut [N]; fn as_mut_slice(&mut self) -> &mut [N];
} }

View File

@ -7,9 +7,6 @@ use na::{
Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5, Matrix4x3, Matrix4x5, Matrix5, Matrix6, MatrixMN, RowVector3, RowVector4, RowVector5,
Vector1, Vector2, Vector3, Vector4, Vector5, Vector6, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6,
}; };
use typenum::{UInt, UTerm};
use serde_json::error::Category::Data;
use typenum::bit::{B0, B1};
#[test] #[test]
fn iter() { fn iter() {

View File

@ -130,7 +130,7 @@ fn matrix5_try_inverse_scaled_identity() {
0.0, 1.0e+20, 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, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0e+20, 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"); let a_inv = a.try_inverse().expect("Matrix should be invertible");
assert_relative_eq!(a_inv, expected_inverse); assert_relative_eq!(a_inv, expected_inverse);