@@ -50,7 +50,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
5050use rustc_mir_dataflow:: move_paths:: MoveData ;
5151use rustc_mir_dataflow:: ResultsCursor ;
5252
53- use crate :: session_diagnostics:: MoveUnsized ;
53+ use crate :: session_diagnostics:: { MoveUnsized , SimdShuffleLastConst } ;
5454use crate :: {
5555 borrow_set:: BorrowSet ,
5656 constraints:: { OutlivesConstraint , OutlivesConstraintSet } ,
@@ -1426,7 +1426,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14261426 . add_element ( region_vid, term_location) ;
14271427 }
14281428
1429- self . check_call_inputs ( body, term, & sig, args, term_location, * call_source) ;
1429+ self . check_call_inputs ( body, term, func , & sig, args, term_location, * call_source) ;
14301430 }
14311431 TerminatorKind :: Assert { cond, msg, .. } => {
14321432 self . check_operand ( cond, term_location) ;
@@ -1546,33 +1546,44 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15461546 }
15471547 }
15481548
1549+ #[ instrument( level = "debug" , skip( self , body, term, func, term_location, call_source) ) ]
15491550 fn check_call_inputs (
15501551 & mut self ,
15511552 body : & Body < ' tcx > ,
15521553 term : & Terminator < ' tcx > ,
1554+ func : & Operand < ' tcx > ,
15531555 sig : & ty:: FnSig < ' tcx > ,
15541556 args : & [ Operand < ' tcx > ] ,
15551557 term_location : Location ,
15561558 call_source : CallSource ,
15571559 ) {
1558- debug ! ( "check_call_inputs({:?}, {:?})" , sig, args) ;
15591560 if args. len ( ) < sig. inputs ( ) . len ( ) || ( args. len ( ) > sig. inputs ( ) . len ( ) && !sig. c_variadic ) {
15601561 span_mirbug ! ( self , term, "call to {:?} with wrong # of args" , sig) ;
15611562 }
15621563
1563- let func_ty = if let TerminatorKind :: Call { func, .. } = & term. kind {
1564- Some ( func. ty ( body, self . infcx . tcx ) )
1565- } else {
1566- None
1567- } ;
1564+ let func_ty = func. ty ( body, self . infcx . tcx ) ;
1565+ if let ty:: FnDef ( def_id, _) = * func_ty. kind ( ) {
1566+ if self . tcx ( ) . is_intrinsic ( def_id) {
1567+ match self . tcx ( ) . item_name ( def_id) {
1568+ sym:: simd_shuffle => {
1569+ if !matches ! ( args[ 2 ] , Operand :: Constant ( _) ) {
1570+ self . tcx ( )
1571+ . sess
1572+ . emit_err ( SimdShuffleLastConst { span : term. source_info . span } ) ;
1573+ }
1574+ }
1575+ _ => { }
1576+ }
1577+ }
1578+ }
15681579 debug ! ( ?func_ty) ;
15691580
15701581 for ( n, ( fn_arg, op_arg) ) in iter:: zip ( sig. inputs ( ) , args) . enumerate ( ) {
15711582 let op_arg_ty = op_arg. ty ( body, self . tcx ( ) ) ;
15721583
15731584 let op_arg_ty = self . normalize ( op_arg_ty, term_location) ;
15741585 let category = if call_source. from_hir_call ( ) {
1575- ConstraintCategory :: CallArgument ( self . infcx . tcx . erase_regions ( func_ty) )
1586+ ConstraintCategory :: CallArgument ( Some ( self . infcx . tcx . erase_regions ( func_ty) ) )
15761587 } else {
15771588 ConstraintCategory :: Boring
15781589 } ;
0 commit comments