Skip to content

Commit 56566d8

Browse files
Annotate signed type in int_divrem_guard
The way the macro expands, it may sometimes infer "this is a uint, but doesn't impl Neg???" Also, I made the "wrong path for intrinsics" error. These fixes allow integration into libcore.
1 parent a4f5f01 commit 56566d8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/core_simd/src/ops.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333

3434
macro_rules! unsafe_base {
3535
($lhs:ident, $rhs:ident, {$simd_call:ident}, $($_:tt)*) => {
36-
unsafe { $crate::intrinsics::$simd_call($lhs, $rhs) }
36+
unsafe { $crate::simd::intrinsics::$simd_call($lhs, $rhs) }
3737
};
3838
}
3939

@@ -49,7 +49,10 @@ macro_rules! unsafe_base {
4949
macro_rules! wrap_bitshift {
5050
($lhs:ident, $rhs:ident, {$simd_call:ident}, $int:ident) => {
5151
unsafe {
52-
$crate::intrinsics::$simd_call($lhs, $rhs.bitand(Simd::splat(<$int>::BITS as $int - 1)))
52+
$crate::simd::intrinsics::$simd_call(
53+
$lhs,
54+
$rhs.bitand(Simd::splat(<$int>::BITS as $int - 1)),
55+
)
5356
}
5457
};
5558
}
@@ -70,11 +73,13 @@ macro_rules! int_divrem_guard {
7073
if $rhs.lanes_eq(Simd::splat(0)).any() {
7174
panic!($zero);
7275
} else if <$int>::MIN != 0
73-
&& ($lhs.lanes_eq(Simd::splat(<$int>::MIN)) & $rhs.lanes_eq(Simd::splat(-1 as _))).any()
76+
&& ($lhs.lanes_eq(Simd::splat(<$int>::MIN))
77+
// type inference can break here, so cut an SInt to size
78+
& $rhs.lanes_eq(Simd::splat(-1i64 as _))).any()
7479
{
7580
panic!($overflow);
7681
} else {
77-
unsafe { $crate::intrinsics::$simd_call($lhs, $rhs) }
82+
unsafe { $crate::simd::intrinsics::$simd_call($lhs, $rhs) }
7883
}
7984
};
8085
}

0 commit comments

Comments
 (0)