Skip to content

Commit 5dc894e

Browse files
committed
Initial output of cargo fix --edition to 2024
1 parent b42a559 commit 5dc894e

40 files changed

+224
-227
lines changed

benches/bench1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ fn bench_col_iter(bench: &mut test::Bencher)
795795
}
796796

797797
macro_rules! mat_mul {
798-
($modname:ident, $ty:ident, $(($name:ident, $m:expr, $n:expr, $k:expr))+) => {
798+
($modname:ident, $ty:ident, $(($name:ident, $m:expr_2021, $n:expr_2021, $k:expr_2021))+) => {
799799
mod $modname {
800800
use test::{black_box, Bencher};
801801
use ndarray::Array;

examples/bounds_check_elim.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn testvec_as_slice(a: &Vec<f64>) -> f64 {
3434
}
3535
*/
3636

37-
#[no_mangle]
37+
#[unsafe(no_mangle)]
3838
pub fn test1d_single(a: &Array1<f64>, i: usize) -> f64
3939
{
4040
if i < a.len() {
@@ -44,7 +44,7 @@ pub fn test1d_single(a: &Array1<f64>, i: usize) -> f64
4444
}
4545
}
4646

47-
#[no_mangle]
47+
#[unsafe(no_mangle)]
4848
pub fn test1d_single_mut(a: &mut Array1<f64>, i: usize) -> f64
4949
{
5050
if i < a.len() {
@@ -54,7 +54,7 @@ pub fn test1d_single_mut(a: &mut Array1<f64>, i: usize) -> f64
5454
}
5555
}
5656

57-
#[no_mangle]
57+
#[unsafe(no_mangle)]
5858
pub fn test1d_len_of(a: &Array1<f64>) -> f64
5959
{
6060
let a = a;
@@ -65,7 +65,7 @@ pub fn test1d_len_of(a: &Array1<f64>) -> f64
6565
sum
6666
}
6767

68-
#[no_mangle]
68+
#[unsafe(no_mangle)]
6969
pub fn test1d_range(a: &Array1<f64>) -> f64
7070
{
7171
let mut sum = 0.;
@@ -75,7 +75,7 @@ pub fn test1d_range(a: &Array1<f64>) -> f64
7575
sum
7676
}
7777

78-
#[no_mangle]
78+
#[unsafe(no_mangle)]
7979
pub fn test1d_while(a: &Array1<f64>) -> f64
8080
{
8181
let mut sum = 0.;
@@ -87,7 +87,7 @@ pub fn test1d_while(a: &Array1<f64>) -> f64
8787
sum
8888
}
8989

90-
#[no_mangle]
90+
#[unsafe(no_mangle)]
9191
pub fn test2d_ranges(a: &Array2<f64>) -> f64
9292
{
9393
let mut sum = 0.;
@@ -99,7 +99,7 @@ pub fn test2d_ranges(a: &Array2<f64>) -> f64
9999
sum
100100
}
101101

102-
#[no_mangle]
102+
#[unsafe(no_mangle)]
103103
pub fn test2d_whiles(a: &Array2<f64>) -> f64
104104
{
105105
let mut sum = 0.;

src/array_approx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod approx_methods
2929
}
3030

3131
macro_rules! impl_approx_traits {
32-
($approx:ident, $doc:expr) => {
32+
($approx:ident, $doc:expr_2021) => {
3333
mod $approx {
3434
use crate::imp_prelude::*;
3535
use crate::Zip;

src/array_serde.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,9 @@ where
237237
}
238238
};
239239

240-
if let Ok(array) = ArrayBase::from_shape_vec(dim, data) {
241-
Ok(array)
242-
} else {
243-
Err(de::Error::custom("data and dimension must match in size"))
240+
match ArrayBase::from_shape_vec(dim, data) {
241+
Ok(array) => Ok(array),
242+
_ => Err(de::Error::custom("data and dimension must match in size")),
244243
}
245244
}
246245

@@ -282,10 +281,6 @@ where
282281
None => return Err(de::Error::missing_field("dim")),
283282
};
284283

285-
if let Ok(array) = ArrayBase::from_shape_vec(dim, data) {
286-
Ok(array)
287-
} else {
288-
Err(de::Error::custom("data and dimension must match in size"))
289-
}
284+
ArrayBase::from_shape_vec(dim, data).map_err(|_| de::Error::custom("data and dimension must match in size"))
290285
}
291286
}

src/data_traits.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ pub unsafe trait RawDataClone: RawData
8989

9090
#[doc(hidden)]
9191
unsafe fn clone_from_with_ptr(&mut self, other: &Self, ptr: NonNull<Self::Elem>) -> NonNull<Self::Elem>
92-
{
92+
{ unsafe {
9393
let (data, ptr) = other.clone_with_ptr(ptr);
9494
*self = data;
9595
ptr
96-
}
96+
}}
9797
}
9898

9999
/// Array representation trait.
@@ -388,26 +388,26 @@ unsafe impl<A> RawDataClone for OwnedRepr<A>
388388
where A: Clone
389389
{
390390
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
391-
{
391+
{ unsafe {
392392
let mut u = self.clone();
393393
let mut new_ptr = u.as_nonnull_mut();
394394
if size_of::<A>() != 0 {
395395
let our_off = (ptr.as_ptr() as isize - self.as_ptr() as isize) / mem::size_of::<A>() as isize;
396396
new_ptr = new_ptr.offset(our_off);
397397
}
398398
(u, new_ptr)
399-
}
399+
}}
400400

401401
unsafe fn clone_from_with_ptr(&mut self, other: &Self, ptr: NonNull<Self::Elem>) -> NonNull<Self::Elem>
402-
{
402+
{ unsafe {
403403
let our_off = if size_of::<A>() != 0 {
404404
(ptr.as_ptr() as isize - other.as_ptr() as isize) / mem::size_of::<A>() as isize
405405
} else {
406406
0
407407
};
408408
self.clone_from(other);
409409
self.as_nonnull_mut().offset(our_off)
410-
}
410+
}}
411411
}
412412

413413
unsafe impl<A> RawData for ViewRepr<&A>
@@ -622,7 +622,7 @@ unsafe impl<A> RawDataClone for CowRepr<'_, A>
622622
where A: Clone
623623
{
624624
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
625-
{
625+
{ unsafe {
626626
match self {
627627
CowRepr::View(view) => {
628628
let (new_view, ptr) = view.clone_with_ptr(ptr);
@@ -633,10 +633,10 @@ where A: Clone
633633
(CowRepr::Owned(new_data), ptr)
634634
}
635635
}
636-
}
636+
}}
637637

638638
unsafe fn clone_from_with_ptr(&mut self, other: &Self, ptr: NonNull<Self::Elem>) -> NonNull<Self::Elem>
639-
{
639+
{ unsafe {
640640
match (&mut *self, other) {
641641
(CowRepr::View(self_), CowRepr::View(other)) => self_.clone_from_with_ptr(other, ptr),
642642
(CowRepr::Owned(self_), CowRepr::Owned(other)) => self_.clone_from_with_ptr(other, ptr),
@@ -651,7 +651,7 @@ where A: Clone
651651
ptr
652652
}
653653
}
654-
}
654+
}}
655655
}
656656

657657
unsafe impl<'a, A> Data for CowRepr<'a, A>
@@ -731,19 +731,19 @@ impl<A, B> RawDataSubst<B> for OwnedRepr<A>
731731
type Output = OwnedRepr<B>;
732732

733733
unsafe fn data_subst(self) -> Self::Output
734-
{
734+
{ unsafe {
735735
self.data_subst()
736-
}
736+
}}
737737
}
738738

739739
impl<A, B> RawDataSubst<B> for OwnedArcRepr<A>
740740
{
741741
type Output = OwnedArcRepr<B>;
742742

743743
unsafe fn data_subst(self) -> Self::Output
744-
{
744+
{ unsafe {
745745
OwnedArcRepr(Arc::from_raw(Arc::into_raw(self.0) as *const OwnedRepr<B>))
746-
}
746+
}}
747747
}
748748

749749
impl<A, B> RawDataSubst<B> for RawViewRepr<*const A>
@@ -791,10 +791,10 @@ impl<'a, A: 'a, B: 'a> RawDataSubst<B> for CowRepr<'a, A>
791791
type Output = CowRepr<'a, B>;
792792

793793
unsafe fn data_subst(self) -> Self::Output
794-
{
794+
{ unsafe {
795795
match self {
796796
CowRepr::View(view) => CowRepr::View(view.data_subst()),
797797
CowRepr::Owned(owned) => CowRepr::Owned(owned.data_subst()),
798798
}
799-
}
799+
}}
800800
}

src/dimension/conversion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ macro_rules! tuple_type {
106106
}
107107

108108
macro_rules! tuple_expr {
109-
([$self_:expr] $($index:tt)*) => (
109+
([$self_:expr_2021] $($index:tt)*) => (
110110
( $($self_[$index], )* )
111111
);
112112
}
113113

114114
macro_rules! array_expr {
115-
([$self_:expr] $($index:tt)*) => (
115+
([$self_:expr_2021] $($index:tt)*) => (
116116
[$($self_ . $index, )*]
117117
);
118118
}

src/dimension/dim.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ macro_rules! impl_scalar_op {
169169
}
170170

171171
macro_rules! add {
172-
($x:expr, $y:expr) => {
172+
($x:expr_2021, $y:expr_2021) => {
173173
$x += $y;
174174
};
175175
}
176176
macro_rules! sub {
177-
($x:expr, $y:expr) => {
177+
($x:expr_2021, $y:expr_2021) => {
178178
$x -= $y;
179179
};
180180
}
181181
macro_rules! mul {
182-
($x:expr, $y:expr) => {
182+
($x:expr_2021, $y:expr_2021) => {
183183
$x *= $y;
184184
};
185185
}

src/dimension/dimension_trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub trait Dimension:
402402
// Dimension impls
403403

404404
macro_rules! impl_insert_axis_array(
405-
($n:expr) => (
405+
($n:expr_2021) => (
406406
#[inline]
407407
fn insert_axis(&self, axis: Axis) -> Self::Larger {
408408
debug_assert!(axis.index() <= $n);
@@ -878,7 +878,7 @@ impl Dimension for Dim<[Ix; 3]>
878878
let mut stride = *self;
879879
let mut order = Ix3(0, 1, 2);
880880
macro_rules! swap {
881-
($stride:expr, $order:expr, $x:expr, $y:expr) => {
881+
($stride:expr_2021, $order:expr_2021, $x:expr_2021, $y:expr_2021) => {
882882
if ($stride[$x] as isize).abs() > ($stride[$y] as isize).abs() {
883883
$stride.swap($x, $y);
884884
$order.ixm().swap($x, $y);
@@ -904,7 +904,7 @@ impl Dimension for Dim<[Ix; 3]>
904904
}
905905

906906
macro_rules! large_dim {
907-
($n:expr, $name:ident, $pattern:ty, $larger:ty, { $($insert_axis:tt)* }) => (
907+
($n:expr_2021, $name:ident, $pattern:ty, $larger:ty, { $($insert_axis:tt)* }) => (
908908
impl Dimension for Dim<[Ix; $n]> {
909909
const NDIM: Option<usize> = Some($n);
910910
type Pattern = $pattern;

src/dimension/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// Indexing macro for Dim<[usize; N]> this
22
/// gets the index at `$i` in the underlying array
33
macro_rules! get {
4-
($dim:expr, $i:expr) => {
4+
($dim:expr_2021, $i:expr_2021) => {
55
(*$dim.ix())[$i]
66
};
77
}
88
macro_rules! getm {
9-
($dim:expr, $i:expr) => {
9+
($dim:expr_2021, $i:expr_2021) => {
1010
(*$dim.ixm())[$i]
1111
};
1212
}

src/dimension/ndindex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ unsafe impl NdIndex<IxDyn> for Ix
160160
}
161161

162162
macro_rules! ndindex_with_array {
163-
($([$n:expr, $ix_n:ident $($index:tt)*])+) => {
163+
($([$n:expr_2021, $ix_n:ident $($index:tt)*])+) => {
164164
$(
165165
// implement NdIndex<Ix2> for [Ix; 2] and so on
166166
unsafe impl NdIndex<$ix_n> for [Ix; $n] {

0 commit comments

Comments
 (0)