@@ -50,7 +50,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
50
50
use rustc_mir_dataflow:: move_paths:: MoveData ;
51
51
use rustc_mir_dataflow:: ResultsCursor ;
52
52
53
- use crate :: session_diagnostics:: MoveUnsized ;
53
+ use crate :: session_diagnostics:: { MoveUnsized , SimdShuffleLastConst } ;
54
54
use crate :: {
55
55
borrow_set:: BorrowSet ,
56
56
constraints:: { OutlivesConstraint , OutlivesConstraintSet } ,
@@ -1426,7 +1426,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1426
1426
. add_element ( region_vid, term_location) ;
1427
1427
}
1428
1428
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) ;
1430
1430
}
1431
1431
TerminatorKind :: Assert { cond, msg, .. } => {
1432
1432
self . check_operand ( cond, term_location) ;
@@ -1546,33 +1546,44 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1546
1546
}
1547
1547
}
1548
1548
1549
+ #[ instrument( level = "debug" , skip( self , body, term, func, term_location, call_source) ) ]
1549
1550
fn check_call_inputs (
1550
1551
& mut self ,
1551
1552
body : & Body < ' tcx > ,
1552
1553
term : & Terminator < ' tcx > ,
1554
+ func : & Operand < ' tcx > ,
1553
1555
sig : & ty:: FnSig < ' tcx > ,
1554
1556
args : & [ Operand < ' tcx > ] ,
1555
1557
term_location : Location ,
1556
1558
call_source : CallSource ,
1557
1559
) {
1558
- debug ! ( "check_call_inputs({:?}, {:?})" , sig, args) ;
1559
1560
if args. len ( ) < sig. inputs ( ) . len ( ) || ( args. len ( ) > sig. inputs ( ) . len ( ) && !sig. c_variadic ) {
1560
1561
span_mirbug ! ( self , term, "call to {:?} with wrong # of args" , sig) ;
1561
1562
}
1562
1563
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
+ }
1568
1579
debug ! ( ?func_ty) ;
1569
1580
1570
1581
for ( n, ( fn_arg, op_arg) ) in iter:: zip ( sig. inputs ( ) , args) . enumerate ( ) {
1571
1582
let op_arg_ty = op_arg. ty ( body, self . tcx ( ) ) ;
1572
1583
1573
1584
let op_arg_ty = self . normalize ( op_arg_ty, term_location) ;
1574
1585
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) ) )
1576
1587
} else {
1577
1588
ConstraintCategory :: Boring
1578
1589
} ;
0 commit comments