@@ -49,7 +49,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
4949use rustc_mir_dataflow:: move_paths:: MoveData ;
5050use rustc_mir_dataflow:: ResultsCursor ;
5151
52- use crate :: session_diagnostics:: { MoveUnsized , SimdShuffleLastConst } ;
52+ use crate :: session_diagnostics:: { MoveUnsized , SimdIntrinsicArgConst } ;
5353use crate :: {
5454 borrow_set:: BorrowSet ,
5555 constraints:: { OutlivesConstraint , OutlivesConstraintSet } ,
@@ -1666,9 +1666,22 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16661666
16671667 let func_ty = func. ty ( body, self . infcx . tcx ) ;
16681668 if let ty:: FnDef ( def_id, _) = * func_ty. kind ( ) {
1669- if let Some ( sym:: simd_shuffle) = self . tcx ( ) . intrinsic ( def_id) {
1670- if !matches ! ( args[ 2 ] , Spanned { node: Operand :: Constant ( _) , .. } ) {
1671- self . tcx ( ) . dcx ( ) . emit_err ( SimdShuffleLastConst { span : term. source_info . span } ) ;
1669+ // Some of the SIMD intrinsics are special: they need a particular argument to be a constant.
1670+ // (Eventually this should use const-generics, but those are not up for the task yet:
1671+ // https://github.com/rust-lang/rust/issues/85229.)
1672+ if let Some ( name @ ( sym:: simd_shuffle | sym:: simd_insert | sym:: simd_extract) ) =
1673+ self . tcx ( ) . intrinsic ( def_id)
1674+ {
1675+ let idx = match name {
1676+ sym:: simd_shuffle => 2 ,
1677+ _ => 1 ,
1678+ } ;
1679+ if !matches ! ( args[ idx] , Spanned { node: Operand :: Constant ( _) , .. } ) {
1680+ self . tcx ( ) . dcx ( ) . emit_err ( SimdIntrinsicArgConst {
1681+ span : term. source_info . span ,
1682+ arg : idx + 1 ,
1683+ intrinsic : name. to_string ( ) ,
1684+ } ) ;
16721685 }
16731686 }
16741687 }
0 commit comments