Skip to content

Commit

Permalink
Remove is_const_fn in find_mir_or_eval_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Oct 27, 2021
1 parent cc4345a commit 223f580
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 223f580

Please sign in to comment.