Skip to content

Commit

Permalink
first test const-ness, then hook fn call
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 28, 2018
1 parent 506dd70 commit c9b5fac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/librustc_mir/const_eval.rs
Expand Up @@ -246,11 +246,13 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeEvaluator {
ret: Option<mir::BasicBlock>,
) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>> {
debug!("eval_fn_call: {:?}", instance);
if ecx.hook_fn(instance, args, dest)? {
ecx.goto_block(ret)?; // fully evaluated and done
return Ok(None);
}
if !ecx.tcx.is_const_fn(instance.def_id()) {
// Some functions we support even if they are non-const -- but avoid testing
// that for const fn!
if ecx.hook_fn(instance, args, dest)? {
ecx.goto_block(ret)?; // fully evaluated and done
return Ok(None);
}
return Err(
ConstEvalError::NotConst(format!("calling non-const fn `{}`", instance)).into(),
);
Expand Down

0 comments on commit c9b5fac

Please sign in to comment.