@@ -337,25 +337,23 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
337
337
) -> InterpResult < ' tcx , Option < & ' mir mir:: Body < ' tcx > > > {
338
338
debug ! ( "find_mir_or_eval_fn: {:?}" , instance) ;
339
339
340
- // If this function is a `const fn` then as an optimization we can query this
341
- // evaluation immediately.
342
- //
343
- // For the moment we only do this for functions which take no arguments
344
- // (or all arguments are ZSTs) so that we don't memoize too much.
345
- if ecx. tcx . is_const_fn_raw ( instance. def . def_id ( ) ) &&
346
- args. iter ( ) . all ( |a| a. layout . is_zst ( ) )
347
- {
348
- let gid = GlobalId { instance, promoted : None } ;
349
- ecx. eval_const_fn_call ( gid, ret) ?;
350
- return Ok ( None ) ;
351
- }
352
-
353
340
// Only check non-glue functions
354
341
if let ty:: InstanceDef :: Item ( def_id) = instance. def {
355
342
// Execution might have wandered off into other crates, so we cannot do a stability-
356
343
// sensitive check here. But we can at least rule out functions that are not const
357
344
// at all.
358
- if !ecx. tcx . is_const_fn_raw ( def_id) {
345
+ if ecx. tcx . is_const_fn_raw ( def_id) {
346
+ // If this function is a `const fn` then as an optimization we can query this
347
+ // evaluation immediately.
348
+ //
349
+ // For the moment we only do this for functions which take no arguments
350
+ // (or all arguments are ZSTs) so that we don't memoize too much.
351
+ if args. iter ( ) . all ( |a| a. layout . is_zst ( ) ) {
352
+ let gid = GlobalId { instance, promoted : None } ;
353
+ ecx. eval_const_fn_call ( gid, ret) ?;
354
+ return Ok ( None ) ;
355
+ }
356
+ } else {
359
357
// Some functions we support even if they are non-const -- but avoid testing
360
358
// that for const fn! We certainly do *not* want to actually call the fn
361
359
// though, so be sure we return here.
0 commit comments