@@ -226,12 +226,14 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
226
226
self . super_terminator ( terminator, location) ;
227
227
228
228
match terminator. kind {
229
- TerminatorKind :: Call { ref func, .. } => {
229
+ TerminatorKind :: Call { ref func, ref args , .. } => {
230
230
if let ty:: FnDef ( def_id, _) = * func. ty ( self . ccx . body , self . ccx . tcx ) . kind ( ) {
231
231
let fn_sig = self . ccx . tcx . fn_sig ( def_id) ;
232
232
if let Abi :: RustIntrinsic | Abi :: PlatformIntrinsic = fn_sig. abi ( ) {
233
233
let name = self . ccx . tcx . item_name ( def_id) ;
234
- // FIXME(eddyb) use `#[rustc_args_required_const(2)]` for shuffles.
234
+ // FIXME: Find some way to do this without general
235
+ // promotion (hard-code array literals, or compile to
236
+ // `inline const`).
235
237
if name. as_str ( ) . starts_with ( "simd_shuffle" ) {
236
238
self . candidates
237
239
. push ( Candidate :: Argument { bb : location. block , index : 2 } ) ;
@@ -242,7 +244,12 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
242
244
243
245
if let Some ( constant_args) = args_required_const ( self . ccx . tcx , def_id) {
244
246
for index in constant_args {
245
- self . candidates . push ( Candidate :: Argument { bb : location. block , index } ) ;
247
+ // FIXME perform this check in some more sensible place
248
+ if !matches ! ( args[ index] , Operand :: Constant ( _) ) {
249
+ let span = terminator. source_info . span ;
250
+ let msg = format ! ( "argument {} is required to be a constant" , index + 1 ) ;
251
+ self . ccx . tcx . sess . span_err ( span, & msg) ;
252
+ }
246
253
}
247
254
}
248
255
}
0 commit comments