From 223f58085aacb586c06c7dbfaa60b85c1b1f1da4 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Wed, 27 Oct 2021 07:21:17 +0100 Subject: [PATCH] Remove `is_const_fn` in `find_mir_or_eval_fn` --- compiler/rustc_const_eval/src/const_eval/machine.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index e01466f8fe21f..dacd8f7c12cfd 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -265,24 +265,18 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, // Only check non-glue functions if let ty::InstanceDef::Item(def) = instance.def { - let mut is_const_fn = true; - // Execution might have wandered off into other crates, so we cannot do a stability- // sensitive check here. But we can at least rule out functions that are not const // at all. if !ecx.tcx.is_const_fn_raw(def.did) { // allow calling functions marked with #[default_method_body_is_const]. if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) { - is_const_fn = false; + // We certainly do *not* want to actually call the fn + // though, so be sure we return here. + throw_unsup_format!("calling non-const function `{}`", instance) } } - if !is_const_fn { - // We certainly do *not* want to actually call the fn - // though, so be sure we return here. - throw_unsup_format!("calling non-const function `{}`", instance) - } - if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? { // We call another const fn instead. return Self::find_mir_or_eval_fn(ecx, new_instance, _abi, args, _ret, _unwind);