Remove is_const_fn
in find_mir_or_eval_fn
This commit is contained in:
parent
cc4345a1c5
commit
223f58085a
1 changed files with 3 additions and 9 deletions
|
@ -265,23 +265,17 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
|
|
||||||
// Only check non-glue functions
|
// Only check non-glue functions
|
||||||
if let ty::InstanceDef::Item(def) = instance.def {
|
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-
|
// 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
|
// sensitive check here. But we can at least rule out functions that are not const
|
||||||
// at all.
|
// at all.
|
||||||
if !ecx.tcx.is_const_fn_raw(def.did) {
|
if !ecx.tcx.is_const_fn_raw(def.did) {
|
||||||
// allow calling functions marked with #[default_method_body_is_const].
|
// allow calling functions marked with #[default_method_body_is_const].
|
||||||
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
|
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
|
||||||
is_const_fn = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !is_const_fn {
|
|
||||||
// We certainly do *not* want to actually call the fn
|
// We certainly do *not* want to actually call the fn
|
||||||
// though, so be sure we return here.
|
// though, so be sure we return here.
|
||||||
throw_unsup_format!("calling non-const function `{}`", instance)
|
throw_unsup_format!("calling non-const function `{}`", instance)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? {
|
if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? {
|
||||||
// We call another const fn instead.
|
// We call another const fn instead.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue