@@ -391,19 +391,22 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
391
391
ret : Option < mir:: BasicBlock > ,
392
392
) -> EvalResult < ' tcx , Option < & ' mir mir:: Mir < ' tcx > > > {
393
393
debug ! ( "eval_fn_call: {:?}" , instance) ;
394
- // Execution might have wandered off into other crates, so we cannot to a stability-
395
- // sensitive check here. But we can at least rule out functions that are not const
396
- // at all.
397
- if !ecx. tcx . is_const_fn_raw ( instance. def_id ( ) ) {
398
- // Some functions we support even if they are non-const -- but avoid testing
399
- // that for const fn! We certainly do *not* want to actually call the fn
400
- // though, so be sure we return here.
401
- return if ecx. hook_fn ( instance, args, dest) ? {
402
- ecx. goto_block ( ret) ?; // fully evaluated and done
403
- Ok ( None )
404
- } else {
405
- err ! ( MachineError ( format!( "calling non-const function `{}`" , instance) ) )
406
- } ;
394
+ // Only check non-glue functions
395
+ if let ty:: InstanceDef :: Item ( def_id) = instance. def {
396
+ // Execution might have wandered off into other crates, so we cannot to a stability-
397
+ // sensitive check here. But we can at least rule out functions that are not const
398
+ // at all.
399
+ if !ecx. tcx . is_const_fn_raw ( def_id) {
400
+ // Some functions we support even if they are non-const -- but avoid testing
401
+ // that for const fn! We certainly do *not* want to actually call the fn
402
+ // though, so be sure we return here.
403
+ return if ecx. hook_fn ( instance, args, dest) ? {
404
+ ecx. goto_block ( ret) ?; // fully evaluated and done
405
+ Ok ( None )
406
+ } else {
407
+ err ! ( MachineError ( format!( "calling non-const function `{}`" , instance) ) )
408
+ } ;
409
+ }
407
410
}
408
411
// This is a const fn. Call it.
409
412
Ok ( Some ( match ecx. load_mir ( instance. def ) {
0 commit comments