@@ -780,14 +780,11 @@ macro_rules! s(
780
780
r => {
781
781
let in_dim = $crate:: SliceNextDim :: next_in_dim( & r, $in_dim) ;
782
782
let out_dim = $crate:: SliceNextDim :: next_out_dim( & r, $out_dim) ;
783
- #[ allow( unsafe_code) ]
784
- unsafe {
785
- $crate:: SliceInfo :: new_unchecked(
786
- [ $( $stack) * $crate:: s!( @convert r, $s) ] ,
787
- in_dim,
788
- out_dim,
789
- )
790
- }
783
+ (
784
+ [ $( $stack) * $crate:: s!( @convert r, $s) ] ,
785
+ in_dim,
786
+ out_dim,
787
+ )
791
788
}
792
789
}
793
790
} ;
@@ -797,14 +794,11 @@ macro_rules! s(
797
794
r => {
798
795
let in_dim = $crate:: SliceNextDim :: next_in_dim( & r, $in_dim) ;
799
796
let out_dim = $crate:: SliceNextDim :: next_out_dim( & r, $out_dim) ;
800
- #[ allow( unsafe_code) ]
801
- unsafe {
802
- $crate:: SliceInfo :: new_unchecked(
803
- [ $( $stack) * $crate:: s!( @convert r) ] ,
804
- in_dim,
805
- out_dim,
806
- )
807
- }
797
+ (
798
+ [ $( $stack) * $crate:: s!( @convert r) ] ,
799
+ in_dim,
800
+ out_dim,
801
+ )
808
802
}
809
803
}
810
804
} ;
@@ -844,16 +838,11 @@ macro_rules! s(
844
838
} ;
845
839
// empty call, i.e. `s![]`
846
840
( @parse :: core:: marker:: PhantomData :: <$crate:: Ix0 >, :: core:: marker:: PhantomData :: <$crate:: Ix0 >, [ ] ) => {
847
- {
848
- #[ allow( unsafe_code) ]
849
- unsafe {
850
- $crate:: SliceInfo :: new_unchecked(
851
- [ ] ,
852
- :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
853
- :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
854
- )
855
- }
856
- }
841
+ (
842
+ [ ] ,
843
+ :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
844
+ :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
845
+ )
857
846
} ;
858
847
// Catch-all clause for syntax errors
859
848
( @parse $( $t: tt) * ) => { compile_error!( "Invalid syntax in s![] call." ) } ;
@@ -868,12 +857,20 @@ macro_rules! s(
868
857
)
869
858
} ;
870
859
( $( $t: tt) * ) => {
871
- $crate:: s![ @parse
872
- :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
873
- :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
874
- [ ]
875
- $( $t) *
876
- ]
860
+ {
861
+ let ( indices, in_dim, out_dim) = $crate:: s![ @parse
862
+ :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
863
+ :: core:: marker:: PhantomData :: <$crate:: Ix0 >,
864
+ [ ]
865
+ $( $t) *
866
+ ] ;
867
+ // Safety: The `s![@parse ...]` above always constructs the correct
868
+ // values to meet the constraints of `SliceInfo::new_unchecked`.
869
+ #[ allow( unsafe_code) ]
870
+ unsafe {
871
+ $crate:: SliceInfo :: new_unchecked( indices, in_dim, out_dim)
872
+ }
873
+ }
877
874
} ;
878
875
) ;
879
876
0 commit comments